Skip to content

Commit

Permalink
Make example code Terraform 12 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
jckuester committed Jul 5, 2020
1 parent 05582c8 commit c7c6f18
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions examples/sagemaker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

resource "aws_iam_role" "foo" {
name = "terraform-sagemaker-example"
path = "/"
assume_role_policy = "${data.aws_iam_policy_document.assume_role.json}"
name = "terraform-sagemaker-example"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}

data "aws_iam_policy_document" "assume_role" {
statement {
actions = [ "sts:AssumeRole" ]
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = [ "sagemaker.amazonaws.com" ]
type = "Service"
identifiers = ["sagemaker.amazonaws.com"]
}
}
}

resource "aws_iam_policy" "foo" {
name = "terraform-sagemaker-example"
name = "terraform-sagemaker-example"
description = "Allow Sagemaker to create model"
policy = "${data.aws_iam_policy_document.foo.json}"
policy = data.aws_iam_policy_document.foo.json
}

data "aws_iam_policy_document" "foo" {
Expand All @@ -52,7 +52,7 @@ data "aws_iam_policy_document" "foo" {
"ecr:BatchGetImage"
]
resources = [
"*"]
"*"]
}
statement {
effect = "Allow"
Expand All @@ -67,37 +67,37 @@ data "aws_iam_policy_document" "foo" {
}

resource "aws_iam_role_policy_attachment" "foo" {
role = "${aws_iam_role.foo.name}"
policy_arn = "${aws_iam_policy.foo.arn}"
role = aws_iam_role.foo.name
policy_arn = aws_iam_policy.foo.arn
}

resource "random_integer" "bucket_suffix" {
min = 1
max = 99999
min = 1
max = 99999
}

resource "aws_s3_bucket" "foo" {
bucket = "terraform-sagemaker-example-${random_integer.bucket_suffix.result}"
acl = "private"
bucket = "terraform-sagemaker-example-${random_integer.bucket_suffix.result}"
acl = "private"
force_destroy = true
}

resource "aws_s3_bucket_object" "object" {
bucket = "${aws_s3_bucket.foo.bucket}"
bucket = aws_s3_bucket.foo.bucket
key = "model.tar.gz"
source = "model.tar.gz"
}

resource "aws_sagemaker_model" "foo" {
name = "terraform-sagemaker-example"
execution_role_arn = "${aws_iam_role.foo.arn}"
name = "terraform-sagemaker-example"
execution_role_arn = aws_iam_role.foo.arn

primary_container {
image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/foo:latest"
image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/foo:latest"
model_data_url = "https://s3-us-west-2.amazonaws.com/${aws_s3_bucket.foo.bucket}/model.tar.gz"
}

tags {
tags = {
foo = "bar"
}
}
Expand All @@ -106,23 +106,23 @@ resource "aws_sagemaker_endpoint_configuration" "foo" {
name = "terraform-sagemaker-example"

production_variants {
variant_name = "variant-1"
model_name = "${aws_sagemaker_model.foo.name}"
initial_instance_count = 1
instance_type = "ml.t2.medium"
initial_variant_weight = 1
variant_name = "variant-1"
model_name = aws_sagemaker_model.foo.name
initial_instance_count = 1
instance_type = "ml.t2.medium"
initial_variant_weight = 1
}

tags {
tags = {
foo = "bar"
}
}

resource "aws_sagemaker_endpoint" "foo" {
name = "terraform-sagemaker-example"
endpoint_config_name = "${aws_sagemaker_endpoint_configuration.foo.name}"
name = "terraform-sagemaker-example"
endpoint_config_name = aws_sagemaker_endpoint_configuration.foo.name

tags {
tags = {
foo = "bar"
}
}

0 comments on commit c7c6f18

Please sign in to comment.