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