Skip to content

Commit

Permalink
update to terraform 0.12 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
rajholla committed Aug 25, 2020
1 parent 2033379 commit 3f8303b
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 159 deletions.
261 changes: 130 additions & 131 deletions aws/resource_aws_kinesis_firehose_delivery_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2527,104 +2527,103 @@ EOF
// ElasticSearch associated with VPC
var testAccKinesisFirehoseDeliveryStreamBaseElasticsearchVpcConfig = testAccKinesisFirehoseDeliveryStreamBaseConfig + `
data "aws_availability_zones" "available" {
state = "available"
state = "available"
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
}
resource "aws_vpc" "elasticsearch_in_vpc" {
cidr_block = "192.168.0.0/22"
resource "aws_vpc" "elasticsearch_in_vpc" {
cidr_block = "192.168.0.0/22"
tags = {
Name = "terraform-testacc-elasticsearch-domain-in-vpc"
tags = {
Name = "terraform-testacc-elasticsearch-domain-in-vpc"
}
}
}
resource "aws_subnet" "first" {
vpc_id = "${aws_vpc.elasticsearch_in_vpc.id}"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
cidr_block = "192.168.0.0/24"
resource "aws_subnet" "first" {
vpc_id = aws_vpc.elasticsearch_in_vpc.id
availability_zone = data.aws_availability_zones.available.names[0]
cidr_block = "192.168.0.0/24"
tags = {
Name = "tf-acc-elasticsearch-domain-in-vpc-first"
tags = {
Name = "tf-acc-elasticsearch-domain-in-vpc-first"
}
}
}
resource "aws_subnet" "second" {
vpc_id = "${aws_vpc.elasticsearch_in_vpc.id}"
availability_zone = "${data.aws_availability_zones.available.names[1]}"
cidr_block = "192.168.1.0/24"
resource "aws_subnet" "second" {
vpc_id = aws_vpc.elasticsearch_in_vpc.id
availability_zone = data.aws_availability_zones.available.names[1]
cidr_block = "192.168.1.0/24"
tags = {
Name = "tf-acc-elasticsearch-domain-in-vpc-second"
tags = {
Name = "tf-acc-elasticsearch-domain-in-vpc-second"
}
}
}
resource "aws_security_group" "first" {
vpc_id = "${aws_vpc.elasticsearch_in_vpc.id}"
}
resource "aws_security_group" "second" {
vpc_id = "${aws_vpc.elasticsearch_in_vpc.id}"
}
resource "aws_elasticsearch_domain" "test_cluster" {
domain_name = "es-test-%d"
cluster_config {
instance_count = 2
zone_awareness_enabled = true
instance_type = "t2.small.elasticsearch"
resource "aws_security_group" "first" {
vpc_id = aws_vpc.elasticsearch_in_vpc.id
}
ebs_options {
ebs_enabled = true
volume_size = 10
resource "aws_security_group" "second" {
vpc_id = aws_vpc.elasticsearch_in_vpc.id
}
vpc_options {
security_group_ids = ["${aws_security_group.first.id}", "${aws_security_group.second.id}"]
subnet_ids = ["${aws_subnet.first.id}", "${aws_subnet.second.id}"]
resource "aws_elasticsearch_domain" "test_cluster" {
domain_name = "es-test-%d"
cluster_config {
instance_count = 2
zone_awareness_enabled = true
instance_type = "t2.small.elasticsearch"
}
ebs_options {
ebs_enabled = true
volume_size = 10
}
vpc_options {
security_group_ids = [aws_security_group.first.id, aws_security_group.second.id]
subnet_ids = [aws_subnet.first.id, aws_subnet.second.id]
}
}
}
resource "aws_iam_role_policy" "firehose-elasticsearch" {
name = "elasticsearch"
role = "${aws_iam_role.firehose.id}"
policy = <<EOF
resource "aws_iam_role_policy" "firehose-elasticsearch" {
name = "elasticsearch"
role = aws_iam_role.firehose.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"es:*"
],
"Resource": [
"${aws_elasticsearch_domain.test_cluster.arn}",
"${aws_elasticsearch_domain.test_cluster.arn}/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:CreateNetworkInterface",
"ec2:CreateNetworkInterfacePermission",
"ec2:DeleteNetworkInterface"
],
"Resource": [
"*"
]
}
]
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"es:*"
],
"Resource":[
"${aws_elasticsearch_domain.test_cluster.arn}",
"${aws_elasticsearch_domain.test_cluster.arn}/*"
]
},
{
"Effect":"Allow",
"Action":[
"ec2:Describe*",
"ec2:CreateNetworkInterface",
"ec2:CreateNetworkInterfacePermission",
"ec2:DeleteNetworkInterface"
],
"Resource":[
"*"
]
}
]
}
EOF
}
}
`

var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchBasic = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchConfig + `
Expand All @@ -2650,27 +2649,27 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {

var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchVpcBasic = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchVpcConfig + `
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = ["aws_iam_role_policy.firehose-elasticsearch"]
name = "terraform-kinesis-firehose-es-%d"
destination = "elasticsearch"
s3_configuration {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
}
elasticsearch_configuration {
domain_arn = "${aws_elasticsearch_domain.test_cluster.arn}"
role_arn = "${aws_iam_role.firehose.arn}"
index_name = "test"
type_name = "test"
vpc_config {
subnet_ids = ["${aws_subnet.first.id}", "${aws_subnet.second.id}"]
security_group_ids = ["${aws_security_group.first.id}", "${aws_security_group.second.id}"]
role_arn = "${aws_iam_role.firehose.arn}"
}
depends_on = [aws_iam_role_policy.firehose-elasticsearch]
name = "terraform-kinesis-firehose-es-%d"
destination = "elasticsearch"
s3_configuration {
role_arn = aws_iam_role.firehose.arn
bucket_arn = aws_s3_bucket.bucket.arn
}
elasticsearch_configuration {
domain_arn = aws_elasticsearch_domain.test_cluster.arn
role_arn = aws_iam_role.firehose.arn
index_name = "test"
type_name = "test"
vpc_config {
subnet_ids = [aws_subnet.first.id, aws_subnet.second.id]
security_group_ids = [aws_security_group.first.id, aws_security_group.second.id]
role_arn = aws_iam_role.firehose.arn
}
}
}
}
`
var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchUpdate = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchConfig + `
resource "aws_kinesis_firehose_delivery_stream" "test" {
Expand Down Expand Up @@ -2709,37 +2708,37 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {

var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchVpcUpdate = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchVpcConfig + `
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = ["aws_iam_role_policy.firehose-elasticsearch"]
name = "terraform-kinesis-firehose-es-%d"
destination = "elasticsearch"
s3_configuration {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
}
elasticsearch_configuration {
domain_arn = "${aws_elasticsearch_domain.test_cluster.arn}"
role_arn = "${aws_iam_role.firehose.arn}"
index_name = "test"
type_name = "test"
buffering_interval = 500
vpc_config {
subnet_ids = ["${aws_subnet.first.id}", "${aws_subnet.second.id}"]
security_group_ids = ["${aws_security_group.first.id}", "${aws_security_group.second.id}"]
role_arn = "${aws_iam_role.firehose.arn}"
}
processing_configuration {
enabled = false
processors {
type = "Lambda"
parameters {
parameter_name = "LambdaArn"
parameter_value = "${aws_lambda_function.lambda_function_test.arn}:$LATEST"
}
}
}
}
}`
depends_on = [aws_iam_role_policy.firehose-elasticsearch]
name = "terraform-kinesis-firehose-es-%d"
destination = "elasticsearch"
s3_configuration {
role_arn = aws_iam_role.firehose.arn
bucket_arn = aws_s3_bucket.bucket.arn
}
elasticsearch_configuration {
domain_arn = aws_elasticsearch_domain.test_cluster.arn
role_arn = aws_iam_role.firehose.arn
index_name = "test"
type_name = "test"
buffering_interval = 500
vpc_config {
subnet_ids = [aws_subnet.first.id, aws_subnet.second.id]
security_group_ids = [aws_security_group.first.id, aws_security_group.second.id]
role_arn = aws_iam_role.firehose.arn
}
processing_configuration {
enabled = false
processors {
type = "Lambda"
parameters {
parameter_name = "LambdaArn"
parameter_value = "${aws_lambda_function.lambda_function_test.arn}:$LATEST"
}
}
}
}
}`

func testAccKinesisFirehoseDeliveryStreamConfig_missingProcessingConfiguration(rInt int) string {
return fmt.Sprintf(`
Expand Down
56 changes: 28 additions & 28 deletions website/docs/r/kinesis_firehose_delivery_stream.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ resource "aws_elasticsearch_domain" "test_cluster" {
}
vpc_options {
security_group_ids = ["${aws_security_group.first.id}"]
subnet_ids = ["${aws_subnet.first.id}", "${aws_subnet.second.id}"]
security_group_ids = [aws_security_group.first.id]
subnet_ids = [aws_subnet.first.id, aws_subnet.second.id]
}
}
resource "aws_iam_role_policy" "firehose-elasticsearch" {
name = "elasticsearch"
role = "${aws_iam_role.firehose.id}"
role = aws_iam_role.firehose.id
policy = <<EOF
{
"Version": "2012-10-17",
Expand All @@ -258,47 +258,47 @@ resource "aws_iam_role_policy" "firehose-elasticsearch" {
"${aws_elasticsearch_domain.test_cluster.arn}",
"${aws_elasticsearch_domain.test_cluster.arn}/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcs",
"ec2:DescribeVpcAttribute",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeNetworkInterfaces",
"ec2:CreateNetworkInterface",
"ec2:CreateNetworkInterfacePermission",
"ec2:DeleteNetworkInterface"
],
"Resource": [
"*"
]
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcs",
"ec2:DescribeVpcAttribute",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeNetworkInterfaces",
"ec2:CreateNetworkInterface",
"ec2:CreateNetworkInterfacePermission",
"ec2:DeleteNetworkInterface"
],
"Resource": [
"*"
]
}
]
}
EOF
}
resource "aws_kinesis_firehose_delivery_stream" "test" {
depends_on = ["aws_iam_role_policy.firehose-elasticsearch"]
depends_on = [aws_iam_role_policy.firehose-elasticsearch]
name = "terraform-kinesis-firehose-es"
destination = "elasticsearch"
s3_configuration {
role_arn = "${aws_iam_role.firehose.arn}"
bucket_arn = "${aws_s3_bucket.bucket.arn}"
role_arn = aws_iam_role.firehose.arn
bucket_arn = aws_s3_bucket.bucket.arn
}
elasticsearch_configuration {
domain_arn = "${aws_elasticsearch_domain.test_cluster.arn}"
role_arn = "${aws_iam_role.firehose.arn}"
domain_arn = aws_elasticsearch_domain.test_cluster.arn
role_arn = aws_iam_role.firehose.arn
index_name = "test"
type_name = "test"
vpc_config {
subnet_ids = ["${aws_subnet.first.id}", "${aws_subnet.second.id}"]
security_group_ids = ["${aws_security_group.first.id}"]
role_arn = "${aws_iam_role.firehose.arn}"
subnet_ids = [aws_subnet.first.id, aws_subnet.second.id]
security_group_ids = [aws_security_group.first.id]
role_arn = aws_iam_role.firehose.arn
}
}
}
Expand Down

0 comments on commit 3f8303b

Please sign in to comment.