Skip to content

Commit

Permalink
Merge pull request #15678 from terraform-providers/t-gov-hardarn-sage
Browse files Browse the repository at this point in the history
tests/provider: Fix hardcoded ARN (Sagemaker Model)
  • Loading branch information
YakDriver authored Oct 16, 2020
2 parents e290bd8 + 589765d commit 2534d4d
Showing 1 changed file with 46 additions and 47 deletions.
93 changes: 46 additions & 47 deletions aws/resource_aws_sagemaker_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ func testAccCheckSagemakerModelExists(n string) resource.TestCheckFunc {
func testAccSagemakerModelConfig(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
image = "%[2]s"
}
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -359,17 +359,17 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerModelConfigTags(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
image = "%[2]s"
}
tags = {
Expand All @@ -378,7 +378,7 @@ resource "aws_sagemaker_model" "foo" {
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -393,17 +393,17 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerModelConfigTagsUpdate(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
image = "%[2]s"
}
tags = {
Expand All @@ -412,7 +412,7 @@ resource "aws_sagemaker_model" "foo" {
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -427,23 +427,23 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerPrimaryContainerModelDataUrlConfig(rName string, image string, modelDataUrl string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
model_data_url = "%s"
image = "%[2]s"
model_data_url = "%[3]s"
}
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -460,7 +460,7 @@ data "aws_iam_policy_document" "assume_role" {
}
resource "aws_iam_policy" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
description = "Allow Sagemaker to create model"
policy = data.aws_iam_policy_document.foo.json
}
Expand Down Expand Up @@ -494,8 +494,7 @@ data "aws_iam_policy_document" "foo" {
]
resources = [
"arn:aws:s3:::${aws_s3_bucket.foo.bucket}",
"arn:aws:s3:::${aws_s3_bucket.foo.bucket}/*",
"${aws_s3_bucket.foo.arn}/*",
]
}
}
Expand All @@ -506,7 +505,7 @@ resource "aws_iam_role_policy_attachment" "foo" {
}
resource "aws_s3_bucket" "foo" {
bucket = "terraform-testacc-sagemaker-model-data-bucket-%s"
bucket = "terraform-testacc-sagemaker-model-data-bucket-%[1]s"
acl = "private"
force_destroy = true
}
Expand All @@ -516,23 +515,23 @@ resource "aws_s3_bucket_object" "object" {
key = "model.tar.gz"
content = "some-data"
}
`, rName, image, modelDataUrl, rName, rName, rName)
`, rName, image, modelDataUrl)
}

func testAccSagemakerPrimaryContainerHostnameConfig(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
image = "%[2]s"
container_hostname = "foo"
}
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -547,17 +546,17 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerPrimaryContainerEnvironmentConfig(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
primary_container {
image = "%s"
image = "%[2]s"
environment = {
foo = "bar"
Expand All @@ -566,7 +565,7 @@ resource "aws_sagemaker_model" "foo" {
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -581,26 +580,26 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerModelContainers(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
container {
image = "%s"
image = "%[2]s"
}
container {
image = "%s"
image = "%[2]s"
}
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -615,23 +614,23 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, image, rName)
`, rName, image)
}

func testAccSagemakerModelNetworkIsolation(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
enable_network_isolation = true
primary_container {
image = "%s"
image = "%[2]s"
}
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -646,18 +645,18 @@ data "aws_iam_policy_document" "assume_role" {
}
}
}
`, rName, image, rName)
`, rName, image)
}

func testAccSagemakerModelVpcConfig(rName string, image string) string {
return fmt.Sprintf(`
resource "aws_sagemaker_model" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
execution_role_arn = aws_iam_role.foo.arn
enable_network_isolation = true
primary_container {
image = "%s"
image = "%[2]s"
}
vpc_config {
Expand All @@ -667,7 +666,7 @@ resource "aws_sagemaker_model" "foo" {
}
resource "aws_iam_role" "foo" {
name = "terraform-testacc-sagemaker-model-%s"
name = "terraform-testacc-sagemaker-model-%[1]s"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
Expand All @@ -687,7 +686,7 @@ resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
tags = {
Name = "terraform-testacc-sagemaker-model-%s"
Name = "terraform-testacc-sagemaker-model-%[1]s"
}
}
Expand All @@ -697,7 +696,7 @@ resource "aws_subnet" "foo" {
vpc_id = aws_vpc.foo.id
tags = {
Name = "terraform-testacc-sagemaker-model-foo-%s"
Name = "terraform-testacc-sagemaker-model-foo-%[1]s"
}
}
Expand All @@ -707,18 +706,18 @@ resource "aws_subnet" "bar" {
vpc_id = aws_vpc.foo.id
tags = {
Name = "terraform-testacc-sagemaker-model-bar-%s"
Name = "terraform-testacc-sagemaker-model-bar-%[1]s"
}
}
resource "aws_security_group" "foo" {
name = "terraform-testacc-sagemaker-model-foo-%s"
name = "terraform-testacc-sagemaker-model-foo-%[1]s"
vpc_id = aws_vpc.foo.id
}
resource "aws_security_group" "bar" {
name = "terraform-testacc-sagemaker-model-bar-%s"
name = "terraform-testacc-sagemaker-model-bar-%[1]s"
vpc_id = aws_vpc.foo.id
}
`, rName, image, rName, rName, rName, rName, rName, rName)
`, rName, image)
}

0 comments on commit 2534d4d

Please sign in to comment.