-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from NetApp/add_secret_rotate
Add an AWS Secret Manager FSxN rotate function
- Loading branch information
Showing
18 changed files
with
793 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,40 @@ | ||
# | ||
# Generate a random password for FSx | ||
resource "random_string" "fsx_password" { | ||
length = 8 | ||
min_lower = 1 | ||
min_numeric = 1 | ||
min_special = 0 | ||
min_upper = 1 | ||
numeric = true | ||
special = true | ||
override_special = "@$%^&*()_+=" | ||
} | ||
|
||
provider "aws" { | ||
alias = "secrets_provider" | ||
region = var.aws_secrets_region | ||
} | ||
# | ||
# Store the password in AWS Secrets Manager | ||
resource "aws_secretsmanager_secret" "fsx_secret_password" { | ||
provider = aws.secrets_provider | ||
name = "${var.fsx_password_secret_name}-${random_id.id.hex}" | ||
} | ||
resource "aws_secretsmanager_secret_version" "fsx_secret_password" { | ||
provider = aws.secrets_provider | ||
secret_id = aws_secretsmanager_secret.fsx_secret_password.id | ||
secret_string = jsonencode({username = "vsadmin", password = random_string.fsx_password.result}) | ||
# Instantiate an AWS secret for the FSx ONTAP file system. It will set the initial password for the file system. | ||
module "fsxn_rotate_secret" { | ||
source = "github.com/Netapp/FSx-ONTAP-samples-scripts/Management-Utilities/fsxn-rotate-secret/terraform" | ||
fsx_region = var.aws_region | ||
secret_region = var.aws_secrets_region | ||
aws_account_id = var.aws_account_id | ||
secret_name_prefix = var.secret_name_prefix | ||
fsx_id = aws_fsx_ontap_file_system.eksfs.id | ||
} | ||
# | ||
# Note that this allows traffic from both the private and public subnets. However | ||
# the security groups only allow traffic from the public subnet over port 22 when | ||
# the source has the jump server SG assigned to it. So, basically, it only allows traffic | ||
# from the jump server from the public subnet. | ||
# Create a FSxN file system. | ||
resource "aws_fsx_ontap_file_system" "eksfs" { | ||
storage_capacity = var.fsxn_storage_capacity | ||
subnet_ids = module.vpc.private_subnets | ||
deployment_type = "MULTI_AZ_1" | ||
throughput_capacity = var.fsxn_throughput_capacity | ||
preferred_subnet_id = module.vpc.private_subnets[0] | ||
security_group_ids = [aws_security_group.fsx_sg.id] | ||
fsx_admin_password = random_string.fsx_password.result | ||
route_table_ids = concat(module.vpc.private_route_table_ids, module.vpc.public_route_table_ids) | ||
route_table_ids = concat(module.vpc.private_route_table_ids, module.vpc.public_route_table_ids) | ||
tags = { | ||
Name = var.fsx_name | ||
} | ||
} | ||
# | ||
# Instantiate an AWS secret for the storage virtual machine. It will set the initial password for the SVM. | ||
module "svm_rotate_secret" { | ||
source = "github.com/Netapp/FSx-ONTAP-samples-scripts/Management-Utilities/fsxn-rotate-secret/terraform" | ||
fsx_region = var.aws_region | ||
secret_region = var.aws_secrets_region | ||
aws_account_id = var.aws_account_id | ||
secret_name_prefix = var.secret_name_prefix | ||
svm_id = aws_fsx_ontap_storage_virtual_machine.ekssvm.id | ||
} | ||
# | ||
# Create a vserver and assign the 'vsadmin' the same password as fsxadmin. | ||
resource "aws_fsx_ontap_storage_virtual_machine" "ekssvm" { | ||
file_system_id = aws_fsx_ontap_file_system.eksfs.id | ||
name = "ekssvm" | ||
svm_admin_password = random_string.fsx_password.result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.