Skip to content

Commit

Permalink
Merge pull request #32661 from bpmcd/b-aws_sagemaker_domain-fix_kms_k…
Browse files Browse the repository at this point in the history
…ey_id

Fix Sagemaker Domain KMS Key ID fields
  • Loading branch information
johnsonaj authored Aug 15, 2023
2 parents 189a7ec + b8d55ac commit a4393f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .changelog/32661.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sagemaker_domain: Fix validation on `s3_kms_key_id` in `sharing_settings` and `kms_key_id`
```
12 changes: 5 additions & 7 deletions internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,8 @@ func ResourceDomain() *schema.Resource {
ValidateFunc: validation.StringInSlice(sagemaker.NotebookOutputOption_Values(), false),
},
"s3_kms_key_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
Type: schema.TypeString,
Optional: true,
},
"s3_output_path": {
Type: schema.TypeString,
Expand Down Expand Up @@ -650,10 +649,9 @@ func ResourceDomain() *schema.Resource {
Computed: true,
},
"kms_key_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
ValidateFunc: verify.ValidARN,
Type: schema.TypeString,
ForceNew: true,
Optional: true,
},
"retention_policy": {
Type: schema.TypeList,
Expand Down
10 changes: 5 additions & 5 deletions internal/service/sagemaker/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func testAccDomain_kms(t *testing.T) {
Config: testAccDomainConfig_kms(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDomainExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", "aws_kms_key.test", "key_id"),
),
},
{
Expand Down Expand Up @@ -233,7 +233,7 @@ func testAccDomain_sharingSettings(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.0.notebook_output_option", "Allowed"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "key_id"),
resource.TestCheckResourceAttrSet(resourceName, "default_user_settings.0.sharing_settings.0.s3_output_path"),
),
},
Expand Down Expand Up @@ -751,7 +751,7 @@ func testAccDomain_defaultUserSettingsUpdated(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.0.notebook_output_option", "Allowed"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "key_id"),
resource.TestCheckResourceAttrSet(resourceName, "default_user_settings.0.sharing_settings.0.s3_output_path"),
),
},
Expand Down Expand Up @@ -954,7 +954,7 @@ resource "aws_sagemaker_domain" "test" {
auth_mode = "IAM"
vpc_id = aws_vpc.test.id
subnet_ids = aws_subnet.test[*].id
kms_key_id = aws_kms_key.test.arn
kms_key_id = aws_kms_key.test.key_id
default_user_settings {
execution_role = aws_iam_role.test.arn
Expand Down Expand Up @@ -1098,7 +1098,7 @@ resource "aws_sagemaker_domain" "test" {
sharing_settings {
notebook_output_option = "Allowed"
s3_kms_key_id = aws_kms_key.test.arn
s3_kms_key_id = aws_kms_key.test.key_id
s3_output_path = "s3://${aws_s3_bucket.test.bucket}/sharing"
}
}
Expand Down

0 comments on commit a4393f9

Please sign in to comment.