Merge pull request #11827 from hashicorp/f-redshift-sg-acctests
provider/aws: Update Redshift SG Acctests
This commit is contained in:
commit
057341acf8
|
@ -4,6 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ func TestAccAWSRedshiftSecurityGroup_importBasic(t *testing.T) {
|
||||||
oldvar := os.Getenv("AWS_DEFAULT_REGION")
|
oldvar := os.Getenv("AWS_DEFAULT_REGION")
|
||||||
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
|
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
|
||||||
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)
|
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resourceName := "aws_redshift_security_group.bar"
|
resourceName := "aws_redshift_security_group.bar"
|
||||||
|
|
||||||
|
@ -19,11 +21,11 @@ func TestAccAWSRedshiftSecurityGroup_importBasic(t *testing.T) {
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr(rInt),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
ResourceName: resourceName,
|
ResourceName: resourceName,
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
|
|
|
@ -7,24 +7,26 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/redshift"
|
"github.com/aws/aws-sdk-go/service/redshift"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSRedshiftSecurityGroup_ingressCidr(t *testing.T) {
|
func TestAccAWSRedshiftSecurityGroup_ingressCidr(t *testing.T) {
|
||||||
var v redshift.ClusterSecurityGroup
|
var v redshift.ClusterSecurityGroup
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_redshift_security_group.bar", "name", "redshift-sg-terraform"),
|
"aws_redshift_security_group.bar", "name", fmt.Sprintf("redshift-sg-terraform-%d", rInt)),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_redshift_security_group.bar", "description", "Managed by Terraform"),
|
"aws_redshift_security_group.bar", "description", "Managed by Terraform"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -39,14 +41,15 @@ func TestAccAWSRedshiftSecurityGroup_ingressCidr(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSRedshiftSecurityGroup_updateIngressCidr(t *testing.T) {
|
func TestAccAWSRedshiftSecurityGroup_updateIngressCidr(t *testing.T) {
|
||||||
var v redshift.ClusterSecurityGroup
|
var v redshift.ClusterSecurityGroup
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -54,8 +57,8 @@ func TestAccAWSRedshiftSecurityGroup_updateIngressCidr(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidrAdd,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidrAdd(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -63,8 +66,8 @@ func TestAccAWSRedshiftSecurityGroup_updateIngressCidr(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidrReduce,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidrReduce(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -77,24 +80,23 @@ func TestAccAWSRedshiftSecurityGroup_updateIngressCidr(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSRedshiftSecurityGroup_ingressSecurityGroup(t *testing.T) {
|
func TestAccAWSRedshiftSecurityGroup_ingressSecurityGroup(t *testing.T) {
|
||||||
var v redshift.ClusterSecurityGroup
|
var v redshift.ClusterSecurityGroup
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgId,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgId(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_redshift_security_group.bar", "name", "redshift-sg-terraform"),
|
"aws_redshift_security_group.bar", "name", fmt.Sprintf("redshift-sg-terraform-%d", rInt)),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_redshift_security_group.bar", "description", "this is a description"),
|
"aws_redshift_security_group.bar", "description", "this is a description"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_redshift_security_group.bar", "ingress.#", "1"),
|
"aws_redshift_security_group.bar", "ingress.#", "1"),
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"aws_redshift_security_group.bar", "ingress.2230908922.security_group_name", "terraform_redshift_acceptance_test"),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -103,14 +105,15 @@ func TestAccAWSRedshiftSecurityGroup_ingressSecurityGroup(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSRedshiftSecurityGroup_updateIngressSecurityGroup(t *testing.T) {
|
func TestAccAWSRedshiftSecurityGroup_updateIngressSecurityGroup(t *testing.T) {
|
||||||
var v redshift.ClusterSecurityGroup
|
var v redshift.ClusterSecurityGroup
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgId,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgId(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -118,8 +121,8 @@ func TestAccAWSRedshiftSecurityGroup_updateIngressSecurityGroup(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgIdAdd,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgIdAdd(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -127,8 +130,8 @@ func TestAccAWSRedshiftSecurityGroup_updateIngressSecurityGroup(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgIdReduce,
|
Config: testAccAWSRedshiftSecurityGroupConfig_ingressSgIdReduce(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
testAccCheckAWSRedshiftSecurityGroupExists("aws_redshift_security_group.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -239,187 +242,199 @@ func TestResourceAWSRedshiftSecurityGroupNameValidation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressCidr = `
|
func testAccAWSRedshiftSecurityGroupConfig_ingressCidr(rInt int) string {
|
||||||
provider "aws" {
|
return fmt.Sprintf(`
|
||||||
region = "us-east-1"
|
provider "aws" {
|
||||||
}
|
region = "us-east-1"
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
|
||||||
name = "redshift-sg-terraform"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.0.1/24"
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressCidrAdd = `
|
|
||||||
provider "aws" {
|
|
||||||
region = "us-east-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
|
||||||
name = "redshift-sg-terraform"
|
|
||||||
description = "this is a description"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.0.1/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.10.1/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.20.1/24"
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressCidrReduce = `
|
|
||||||
provider "aws" {
|
|
||||||
region = "us-east-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
|
||||||
name = "redshift-sg-terraform"
|
|
||||||
description = "this is a description"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.0.1/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
cidr = "10.0.10.1/24"
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressSgId = `
|
|
||||||
provider "aws" {
|
|
||||||
region = "us-east-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_security_group" "redshift" {
|
|
||||||
name = "terraform_redshift_acceptance_test"
|
|
||||||
description = "Used in the redshift acceptance tests"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.0.0.0/8"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.0.1/24"
|
||||||
|
}
|
||||||
|
}`, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
func testAccAWSRedshiftSecurityGroupConfig_ingressCidrAdd(rInt int) string {
|
||||||
name = "redshift-sg-terraform"
|
return fmt.Sprintf(`
|
||||||
description = "this is a description"
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
ingress {
|
|
||||||
security_group_name = "${aws_security_group.redshift.name}"
|
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressSgIdAdd = `
|
|
||||||
provider "aws" {
|
|
||||||
region = "us-east-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_security_group" "redshift" {
|
|
||||||
name = "terraform_redshift_acceptance_test"
|
|
||||||
description = "Used in the redshift acceptance tests"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.0.0.0/16"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
description = "this is a description"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.0.1/24"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.10.1/24"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.20.1/24"
|
||||||
|
}
|
||||||
|
}`, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_security_group" "redshift2" {
|
func testAccAWSRedshiftSecurityGroupConfig_ingressCidrReduce(rInt int) string {
|
||||||
name = "terraform_redshift_acceptance_test_2"
|
return fmt.Sprintf(`
|
||||||
description = "Used in the redshift acceptance tests #2"
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.1.0.0/16"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
description = "this is a description"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.0.1/24"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
cidr = "10.0.10.1/24"
|
||||||
|
}
|
||||||
|
}`, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_security_group" "redshift3" {
|
func testAccAWSRedshiftSecurityGroupConfig_ingressSgId(rInt int) string {
|
||||||
name = "terraform_redshift_acceptance_test_3"
|
return fmt.Sprintf(`
|
||||||
description = "Used in the redshift acceptance tests #3"
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.2.0.0/16"]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
resource "aws_security_group" "redshift" {
|
||||||
name = "redshift-sg-terraform"
|
name = "terraform_redshift_test_%d"
|
||||||
description = "this is a description"
|
description = "Used in the redshift acceptance tests"
|
||||||
|
|
||||||
ingress {
|
ingress {
|
||||||
security_group_name = "${aws_security_group.redshift.name}"
|
protocol = "tcp"
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
from_port = 22
|
||||||
}
|
to_port = 22
|
||||||
|
cidr_blocks = ["10.0.0.0/8"]
|
||||||
ingress {
|
}
|
||||||
security_group_name = "${aws_security_group.redshift2.name}"
|
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
security_group_name = "${aws_security_group.redshift3.name}"
|
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
||||||
const testAccAWSRedshiftSecurityGroupConfig_ingressSgIdReduce = `
|
|
||||||
provider "aws" {
|
|
||||||
region = "us-east-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_security_group" "redshift" {
|
|
||||||
name = "terraform_redshift_acceptance_test"
|
|
||||||
description = "Used in the redshift acceptance tests"
|
|
||||||
|
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.0.0.0/16"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
description = "this is a description"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
}`, rInt, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_security_group" "redshift2" {
|
func testAccAWSRedshiftSecurityGroupConfig_ingressSgIdAdd(rInt int) string {
|
||||||
name = "terraform_redshift_acceptance_test_2"
|
return fmt.Sprintf(`
|
||||||
description = "Used in the redshift acceptance tests #2"
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
ingress {
|
|
||||||
protocol = "tcp"
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
cidr_blocks = ["10.1.0.0/16"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "redshift" {
|
||||||
|
name = "terraform_redshift_test_%d"
|
||||||
|
description = "Used in the redshift acceptance tests"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
protocol = "tcp"
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
cidr_blocks = ["10.0.0.0/16"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "redshift2" {
|
||||||
|
name = "terraform_redshift_test_2_%d"
|
||||||
|
description = "Used in the redshift acceptance tests #2"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
protocol = "tcp"
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
cidr_blocks = ["10.1.0.0/16"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "redshift3" {
|
||||||
|
name = "terraform_redshift_test_3_%d"
|
||||||
|
description = "Used in the redshift acceptance tests #3"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
protocol = "tcp"
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
cidr_blocks = ["10.2.0.0/16"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
description = "this is a description"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift2.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift3.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
}`, rInt, rInt, rInt, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_redshift_security_group" "bar" {
|
func testAccAWSRedshiftSecurityGroupConfig_ingressSgIdReduce(rInt int) string {
|
||||||
name = "redshift-sg-terraform"
|
return fmt.Sprintf(`
|
||||||
description = "this is a description"
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
|
}
|
||||||
|
|
||||||
ingress {
|
resource "aws_security_group" "redshift" {
|
||||||
security_group_name = "${aws_security_group.redshift.name}"
|
name = "terraform_redshift_test_%d"
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
description = "Used in the redshift acceptance tests"
|
||||||
}
|
|
||||||
|
|
||||||
ingress {
|
ingress {
|
||||||
security_group_name = "${aws_security_group.redshift2.name}"
|
protocol = "tcp"
|
||||||
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
from_port = 22
|
||||||
}
|
to_port = 22
|
||||||
}`
|
cidr_blocks = ["10.0.0.0/16"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "redshift2" {
|
||||||
|
name = "terraform_redshift_test_2_%d"
|
||||||
|
description = "Used in the redshift acceptance tests #2"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
protocol = "tcp"
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
cidr_blocks = ["10.1.0.0/16"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_redshift_security_group" "bar" {
|
||||||
|
name = "redshift-sg-terraform-%d"
|
||||||
|
description = "this is a description"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
security_group_name = "${aws_security_group.redshift2.name}"
|
||||||
|
security_group_owner_id = "${aws_security_group.redshift.owner_id}"
|
||||||
|
}
|
||||||
|
}`, rInt, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue