-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
f/aws_fsx_lustre_file_system specify custom KMS Key #15057
Changes from 17 commits
1cf3995
1138cb1
9f6f591
62af651
bc0219f
4875d2f
55a1184
d5889b1
8b564f7
919a1d5
1a0f5dd
9305b8b
36c9331
9eab2ac
e372705
2301bd0
ca7d23a
07ac294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -432,6 +432,7 @@ func TestAccAWSFsxLustreFileSystem_automaticBackupRetentionDays(t *testing.T) { | |||||||||
func TestAccAWSFsxLustreFileSystem_DeploymentTypePersistent1(t *testing.T) { | ||||||||||
var filesystem fsx.FileSystem | ||||||||||
resourceName := "aws_fsx_lustre_file_system.test" | ||||||||||
datakmsKeyArn := "data.aws_kms_alias.fsx" | ||||||||||
|
||||||||||
resource.ParallelTest(t, resource.TestCase{ | ||||||||||
PreCheck: func() { testAccPreCheck(t) }, | ||||||||||
|
@@ -446,6 +447,7 @@ func TestAccAWSFsxLustreFileSystem_DeploymentTypePersistent1(t *testing.T) { | |||||||||
resource.TestCheckResourceAttr(resourceName, "per_unit_storage_throughput", "50"), | ||||||||||
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypePersistent1), | ||||||||||
resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "0"), | ||||||||||
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", datakmsKeyArn, "target_key_arn"), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified |
||||||||||
), | ||||||||||
}, | ||||||||||
{ | ||||||||||
|
@@ -458,6 +460,44 @@ func TestAccAWSFsxLustreFileSystem_DeploymentTypePersistent1(t *testing.T) { | |||||||||
}) | ||||||||||
} | ||||||||||
|
||||||||||
func TestAccAWSFsxLustreFileSystem_KmsKeyId(t *testing.T) { | ||||||||||
var filesystem1, filesystem2 fsx.FileSystem | ||||||||||
resourceName := "aws_fsx_lustre_file_system.test" | ||||||||||
kmsKeyResourceName1 := "aws_kms_key.test1" | ||||||||||
kmsKeyResourceName2 := "aws_kms_key.test2" | ||||||||||
|
||||||||||
resource.ParallelTest(t, resource.TestCase{ | ||||||||||
PreCheck: func() { testAccPreCheck(t) }, | ||||||||||
Providers: testAccProviders, | ||||||||||
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy, | ||||||||||
Steps: []resource.TestStep{ | ||||||||||
{ | ||||||||||
Config: testAccAwsFsxLustreFileSystemConfigKmsKeyId1(), | ||||||||||
Check: resource.ComposeTestCheckFunc( | ||||||||||
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem1), | ||||||||||
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypePersistent1), | ||||||||||
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", kmsKeyResourceName1, "arn"), | ||||||||||
), | ||||||||||
}, | ||||||||||
{ | ||||||||||
ResourceName: resourceName, | ||||||||||
ImportState: true, | ||||||||||
ImportStateVerify: true, | ||||||||||
ImportStateVerifyIgnore: []string{"security_group_ids"}, | ||||||||||
}, | ||||||||||
{ | ||||||||||
Config: testAccAwsFsxLustreFileSystemConfigKmsKeyId2(), | ||||||||||
Check: resource.ComposeTestCheckFunc( | ||||||||||
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem2), | ||||||||||
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypePersistent1), | ||||||||||
testAccCheckFsxWindowsFileSystemRecreated(&filesystem1, &filesystem2), | ||||||||||
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", kmsKeyResourceName2, "arn"), | ||||||||||
), | ||||||||||
}, | ||||||||||
}, | ||||||||||
}) | ||||||||||
} | ||||||||||
|
||||||||||
func TestAccAWSFsxLustreFileSystem_DeploymentTypeScratch2(t *testing.T) { | ||||||||||
var filesystem fsx.FileSystem | ||||||||||
resourceName := "aws_fsx_lustre_file_system.test" | ||||||||||
|
@@ -786,5 +826,43 @@ resource "aws_fsx_lustre_file_system" "test" { | |||||||||
deployment_type = "PERSISTENT_1" | ||||||||||
per_unit_storage_throughput = %[1]d | ||||||||||
} | ||||||||||
|
||||||||||
data "aws_kms_alias" "fsx" { | ||||||||||
name = "alias/aws/fsx" | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this KMS Key guaranteed to exist in AWS accounts that have not provisioned FSx before? Generally, AWS-managed keys are not created until then. It might be best to remove this here and update the test step to just check for a regular expression so there is not a test dependency the first run in a new account.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is a valid reason, either we can add regex match or just remove the check, since it has to be kms by default and we don't need to verify it.(how it was before) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was able to confirm in a separate AWS account that the FSx KMS Key and its associated Alias is not automatically available. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||||||||||
`, perUnitStorageThroughput) | ||||||||||
} | ||||||||||
|
||||||||||
func testAccAwsFsxLustreFileSystemConfigKmsKeyId1() string { | ||||||||||
return testAccAwsFsxLustreFileSystemConfigBase() + ` | ||||||||||
resource "aws_kms_key" "test1" { | ||||||||||
description = "FSx KMS Testing key" | ||||||||||
deletion_window_in_days = 7 | ||||||||||
} | ||||||||||
|
||||||||||
resource "aws_fsx_lustre_file_system" "test" { | ||||||||||
storage_capacity = 1200 | ||||||||||
subnet_ids = [aws_subnet.test1.id] | ||||||||||
deployment_type = "PERSISTENT_1" | ||||||||||
per_unit_storage_throughput = 50 | ||||||||||
kms_key_id = aws_kms_key.test1.arn | ||||||||||
} | ||||||||||
` | ||||||||||
} | ||||||||||
|
||||||||||
func testAccAwsFsxLustreFileSystemConfigKmsKeyId2() string { | ||||||||||
return testAccAwsFsxLustreFileSystemConfigBase() + ` | ||||||||||
resource "aws_kms_key" "test2" { | ||||||||||
description = "FSx KMS Testing key" | ||||||||||
deletion_window_in_days = 7 | ||||||||||
} | ||||||||||
|
||||||||||
resource "aws_fsx_lustre_file_system" "test" { | ||||||||||
storage_capacity = 1200 | ||||||||||
subnet_ids = [aws_subnet.test1.id] | ||||||||||
deployment_type = "PERSISTENT_1" | ||||||||||
per_unit_storage_throughput = 50 | ||||||||||
kms_key_id = aws_kms_key.test2.arn | ||||||||||
} | ||||||||||
` | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to below