providers/aws: security group id-only

This commit is contained in:
Mitchell Hashimoto 2016-04-20 16:41:45 -07:00
parent 5f82f38be7
commit a44c547986
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 115 additions and 37 deletions

View File

@ -236,9 +236,10 @@ func TestAccAWSSecurityGroup_basic(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfig, Config: testAccAWSSecurityGroupConfig,
@ -269,9 +270,11 @@ func TestAccAWSSecurityGroup_namePrefix(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.baz",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, IDRefreshIgnore: []string{"name_prefix"},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupPrefixNameConfig, Config: testAccAWSSecurityGroupPrefixNameConfig,
@ -303,9 +306,10 @@ func TestAccAWSSecurityGroup_self(t *testing.T) {
} }
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigSelf, Config: testAccAWSSecurityGroupConfigSelf,
@ -342,9 +346,10 @@ func TestAccAWSSecurityGroup_vpc(t *testing.T) {
} }
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigVpc, Config: testAccAWSSecurityGroupConfigVpc,
@ -394,9 +399,10 @@ func TestAccAWSSecurityGroup_vpcNegOneIngress(t *testing.T) {
} }
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigVpcNegOneIngress, Config: testAccAWSSecurityGroupConfigVpcNegOneIngress,
@ -427,9 +433,10 @@ func TestAccAWSSecurityGroup_MultiIngress(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigMultiIngress, Config: testAccAWSSecurityGroupConfigMultiIngress,
@ -445,9 +452,10 @@ func TestAccAWSSecurityGroup_Change(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfig, Config: testAccAWSSecurityGroupConfig,
@ -470,9 +478,10 @@ func TestAccAWSSecurityGroup_generatedName(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfig_generatedName, Config: testAccAWSSecurityGroupConfig_generatedName,
@ -499,9 +508,10 @@ func TestAccAWSSecurityGroup_DefaultEgress(t *testing.T) {
// VPC // VPC
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.worker",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigDefaultEgress, Config: testAccAWSSecurityGroupConfigDefaultEgress,
@ -515,9 +525,10 @@ func TestAccAWSSecurityGroup_DefaultEgress(t *testing.T) {
// Classic // Classic
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_security_group.web",
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfigClassic, Config: testAccAWSSecurityGroupConfigClassic,
@ -533,9 +544,11 @@ func TestAccAWSSecurityGroup_DefaultEgress(t *testing.T) {
func TestAccAWSSecurityGroup_drift(t *testing.T) { func TestAccAWSSecurityGroup_drift(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, DisableIDRefresh: true,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, IDRefreshName: "aws_security_group.web",
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfig_drift(), Config: testAccAWSSecurityGroupConfig_drift(),
@ -563,9 +576,11 @@ func TestAccAWSSecurityGroup_drift_complex(t *testing.T) {
var group ec2.SecurityGroup var group ec2.SecurityGroup
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, DisableIDRefresh: true,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy, IDRefreshName: "aws_security_group.web",
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSSecurityGroupConfig_drift_complex(), Config: testAccAWSSecurityGroupConfig_drift_complex(),
@ -958,9 +973,14 @@ func testAccCheckAWSSecurityGroupExistsWithoutDefault(n string) resource.TestChe
} }
const testAccAWSSecurityGroupConfig = ` const testAccAWSSecurityGroupConfig = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "6" protocol = "6"
@ -983,9 +1003,14 @@ resource "aws_security_group" "web" {
` `
const testAccAWSSecurityGroupConfigChange = ` const testAccAWSSecurityGroupConfigChange = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1011,9 +1036,14 @@ resource "aws_security_group" "web" {
` `
const testAccAWSSecurityGroupConfigSelf = ` const testAccAWSSecurityGroupConfigSelf = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1076,9 +1106,14 @@ resource "aws_security_group" "web" {
} }
` `
const testAccAWSSecurityGroupConfigMultiIngress = ` const testAccAWSSecurityGroupConfigMultiIngress = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "worker" { resource "aws_security_group" "worker" {
name = "terraform_acceptance_test_example_1" name = "terraform_acceptance_test_example_1"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1098,6 +1133,7 @@ resource "aws_security_group" "worker" {
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example_2" name = "terraform_acceptance_test_example_2"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1130,9 +1166,14 @@ resource "aws_security_group" "web" {
` `
const testAccAWSSecurityGroupConfigTags = ` const testAccAWSSecurityGroupConfigTags = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "foo" { resource "aws_security_group" "foo" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1155,9 +1196,14 @@ resource "aws_security_group" "foo" {
` `
const testAccAWSSecurityGroupConfigTagsUpdate = ` const testAccAWSSecurityGroupConfigTagsUpdate = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "foo" { resource "aws_security_group" "foo" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1180,7 +1226,13 @@ resource "aws_security_group" "foo" {
` `
const testAccAWSSecurityGroupConfig_generatedName = ` const testAccAWSSecurityGroupConfig_generatedName = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
from_port = 80 from_port = 80
@ -1274,14 +1326,20 @@ resource "aws_security_group" "web" {
func testAccAWSSecurityGroupConfig_drift_complex() string { func testAccAWSSecurityGroupConfig_drift_complex() string {
return fmt.Sprintf(` return fmt.Sprintf(`
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "otherweb" { resource "aws_security_group" "otherweb" {
name = "tf_acc_%d" name = "tf_acc_%d"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
} }
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "tf_acc_%d" name = "tf_acc_%d"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1332,8 +1390,13 @@ resource "aws_security_group" "web" {
} }
const testAccAWSSecurityGroupCombindCIDRandGroups = ` const testAccAWSSecurityGroupCombindCIDRandGroups = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "two" { resource "aws_security_group" "two" {
name = "tf-test-1" name = "tf-test-1"
vpc_id = "${aws_vpc.foo.id}"
tags { tags {
Name = "tf-test-1" Name = "tf-test-1"
} }
@ -1341,6 +1404,7 @@ resource "aws_security_group" "two" {
resource "aws_security_group" "one" { resource "aws_security_group" "one" {
name = "tf-test-2" name = "tf-test-2"
vpc_id = "${aws_vpc.foo.id}"
tags { tags {
Name = "tf-test-w" Name = "tf-test-w"
} }
@ -1348,6 +1412,7 @@ resource "aws_security_group" "one" {
resource "aws_security_group" "three" { resource "aws_security_group" "three" {
name = "tf-test-3" name = "tf-test-3"
vpc_id = "${aws_vpc.foo.id}"
tags { tags {
Name = "tf-test-3" Name = "tf-test-3"
} }
@ -1355,6 +1420,7 @@ resource "aws_security_group" "three" {
resource "aws_security_group" "mixed" { resource "aws_security_group" "mixed" {
name = "tf-mix-test" name = "tf-mix-test"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
from_port = 80 from_port = 80
@ -1376,9 +1442,14 @@ resource "aws_security_group" "mixed" {
` `
const testAccAWSSecurityGroupConfig_ingressWithCidrAndSGs = ` const testAccAWSSecurityGroupConfig_ingressWithCidrAndSGs = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "other_web" { resource "aws_security_group" "other_web" {
name = "tf_other_acc_tests" name = "tf_other_acc_tests"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
tags { tags {
Name = "tf-acc-test" Name = "tf-acc-test"
@ -1388,6 +1459,7 @@ resource "aws_security_group" "other_web" {
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"
@ -1425,9 +1497,14 @@ provider "aws" {
region = "us-east-1" region = "us-east-1"
} }
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}
resource "aws_security_group" "other_web" { resource "aws_security_group" "other_web" {
name = "tf_other_acc_tests" name = "tf_other_acc_tests"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
tags { tags {
Name = "tf-acc-test" Name = "tf-acc-test"
@ -1437,6 +1514,7 @@ resource "aws_security_group" "other_web" {
resource "aws_security_group" "web" { resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example" name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests" description = "Used in the terraform acceptance tests"
vpc_id = "${aws_vpc.foo.id}"
ingress { ingress {
protocol = "tcp" protocol = "tcp"