Retire goamz
This commit is contained in:
parent
580b696e7f
commit
28fbd971fc
|
@ -3,8 +3,6 @@ package aws
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
"unicode"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/multierror"
|
"github.com/hashicorp/terraform/helper/multierror"
|
||||||
|
|
||||||
|
@ -41,14 +39,9 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
// Get the auth and region. This can fail if keys/regions were not
|
// Get the auth and region. This can fail if keys/regions were not
|
||||||
// specified and we're attempting to use the environment.
|
// specified and we're attempting to use the environment.
|
||||||
var errs []error
|
var errs []error
|
||||||
log.Println("[INFO] Building AWS auth structure")
|
|
||||||
auth, err := c.AWSAuth()
|
|
||||||
if err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("[INFO] Building AWS region structure")
|
log.Println("[INFO] Building AWS region structure")
|
||||||
region, err := c.AWSRegion()
|
err := c.ValidateRegion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
@ -58,6 +51,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
// bucket storage in S3
|
// bucket storage in S3
|
||||||
client.region = c.Region
|
client.region = c.Region
|
||||||
|
|
||||||
|
log.Println("[INFO] Building AWS auth structure")
|
||||||
creds := aws.Creds(c.AccessKey, c.SecretKey, c.Token)
|
creds := aws.Creds(c.AccessKey, c.SecretKey, c.Token)
|
||||||
|
|
||||||
log.Println("[INFO] Initializing ELB connection")
|
log.Println("[INFO] Initializing ELB connection")
|
||||||
|
@ -75,7 +69,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
log.Println("[INFO] Initializing Route53 connection")
|
log.Println("[INFO] Initializing Route53 connection")
|
||||||
client.r53conn = route53.New(creds, "us-east-1", nil)
|
client.r53conn = route53.New(creds, "us-east-1", nil)
|
||||||
log.Println("[INFO] Initializing EC2 Connection")
|
log.Println("[INFO] Initializing EC2 Connection")
|
||||||
client.awsEC2conn = awsEC2.New(creds, c.Region, nil)
|
client.ec2conn = ec2.New(creds, c.Region, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
@ -85,54 +79,17 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
return &client, nil
|
return &client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AWSAuth returns a valid aws.Auth object for access to AWS services, or
|
|
||||||
// an error if the authentication couldn't be resolved.
|
|
||||||
//
|
|
||||||
// TODO(mitchellh): Test in some way.
|
|
||||||
func (c *Config) AWSAuth() (aws.Auth, error) {
|
|
||||||
auth, err := aws.GetAuth(c.AccessKey, c.SecretKey)
|
|
||||||
if err == nil {
|
|
||||||
// Store the accesskey and secret that we got...
|
|
||||||
c.AccessKey = auth.AccessKey
|
|
||||||
c.SecretKey = auth.SecretKey
|
|
||||||
c.Token = auth.Token
|
|
||||||
}
|
|
||||||
|
|
||||||
return auth, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValidRegion returns true if the configured region is a valid AWS
|
// IsValidRegion returns true if the configured region is a valid AWS
|
||||||
// region and false if it's not
|
// region and false if it's not
|
||||||
func (c *Config) IsValidRegion() bool {
|
func (c *Config) ValidateRegion() error {
|
||||||
var regions = [11]string{"us-east-1", "us-west-2", "us-west-1", "eu-west-1",
|
var regions = [11]string{"us-east-1", "us-west-2", "us-west-1", "eu-west-1",
|
||||||
"eu-central-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1",
|
"eu-central-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1",
|
||||||
"sa-east-1", "cn-north-1", "us-gov-west-1"}
|
"sa-east-1", "cn-north-1", "us-gov-west-1"}
|
||||||
|
|
||||||
for _, valid := range regions {
|
for _, valid := range regions {
|
||||||
if c.Region == valid {
|
if c.Region == valid {
|
||||||
return true
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return fmt.Errorf("Not a valid region: %s", c.Region)
|
||||||
}
|
|
||||||
|
|
||||||
// AWSRegion returns the configured region.
|
|
||||||
//
|
|
||||||
// TODO(mitchellh): Test in some way.
|
|
||||||
func (c *Config) AWSRegion() (aws.Region, error) {
|
|
||||||
if c.Region != "" {
|
|
||||||
if c.IsValidRegion() {
|
|
||||||
return aws.Regions[c.Region], nil
|
|
||||||
} else {
|
|
||||||
return aws.Region{}, fmt.Errorf("Not a valid region: %s", c.Region)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
md, err := aws.GetMetaData("placement/availability-zone")
|
|
||||||
if err != nil {
|
|
||||||
return aws.Region{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
region := strings.TrimRightFunc(string(md), unicode.IsLetter)
|
|
||||||
return aws.Regions[region], nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func resourceAwsEip() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// By default, we're not in a VPC
|
// By default, we're not in a VPC
|
||||||
domainOpt := ""
|
domainOpt := ""
|
||||||
|
@ -97,7 +97,7 @@ func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
domain := resourceAwsEipDomain(d)
|
domain := resourceAwsEipDomain(d)
|
||||||
id := d.Id()
|
id := d.Id()
|
||||||
|
@ -148,7 +148,7 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
domain := resourceAwsEipDomain(d)
|
domain := resourceAwsEipDomain(d)
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
if err := resourceAwsEipRead(d, meta); err != nil {
|
if err := resourceAwsEipRead(d, meta); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -58,7 +58,7 @@ func TestAccAWSEIP_instance(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckAWSEIPDestroy(s *terraform.State) error {
|
func testAccCheckAWSEIPDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_eip" {
|
if rs.Type != "aws_eip" {
|
||||||
|
@ -113,7 +113,7 @@ func testAccCheckAWSEIPExists(n string, res *ec2.Address) resource.TestCheckFunc
|
||||||
return fmt.Errorf("No EIP ID is set")
|
return fmt.Errorf("No EIP ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
if strings.Contains(rs.Primary.ID, "eipalloc") {
|
if strings.Contains(rs.Primary.ID, "eipalloc") {
|
||||||
req := &ec2.DescribeAddressesRequest{
|
req := &ec2.DescribeAddressesRequest{
|
||||||
|
|
|
@ -253,7 +253,7 @@ func resourceAwsInstance() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Figure out user data
|
// Figure out user data
|
||||||
userData := ""
|
userData := ""
|
||||||
|
@ -437,7 +437,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
resp, err := ec2conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
resp, err := ec2conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||||
InstanceIDs: []string{d.Id()},
|
InstanceIDs: []string{d.Id()},
|
||||||
|
@ -561,7 +561,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
opts := new(ec2.ModifyInstanceAttributeRequest)
|
opts := new(ec2.ModifyInstanceAttributeRequest)
|
||||||
|
|
||||||
log.Printf("[INFO] Modifying instance %s: %#v", d.Id(), opts)
|
log.Printf("[INFO] Modifying instance %s: %#v", d.Id(), opts)
|
||||||
|
@ -589,7 +589,7 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInstanceDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInstanceDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf("[INFO] Terminating instance: %s", d.Id())
|
log.Printf("[INFO] Terminating instance: %s", d.Id())
|
||||||
req := &ec2.TerminateInstancesRequest{
|
req := &ec2.TerminateInstancesRequest{
|
||||||
|
|
|
@ -296,7 +296,7 @@ func TestAccAWSInstance_associatePublicIPAndPrivateIP(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckInstanceDestroy(s *terraform.State) error {
|
func testAccCheckInstanceDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_instance" {
|
if rs.Type != "aws_instance" {
|
||||||
|
@ -339,7 +339,7 @@ func testAccCheckInstanceExists(n string, i *ec2.Instance) resource.TestCheckFun
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||||
InstanceIDs: []string{rs.Primary.ID},
|
InstanceIDs: []string{rs.Primary.ID},
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,7 +29,7 @@ func resourceAwsInternetGateway() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Create the gateway
|
// Create the gateway
|
||||||
log.Printf("[DEBUG] Creating internet gateway")
|
log.Printf("[DEBUG] Creating internet gateway")
|
||||||
|
@ -53,7 +53,7 @@ func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInternetGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInternetGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
igRaw, _, err := IGStateRefreshFunc(ec2conn, d.Id())()
|
igRaw, _, err := IGStateRefreshFunc(ec2conn, d.Id())()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -91,7 +91,7 @@ func resourceAwsInternetGatewayUpdate(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
if err := setTags(ec2conn, d); err != nil {
|
if err := setTags(ec2conn, d); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -103,7 +103,7 @@ func resourceAwsInternetGatewayUpdate(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInternetGatewayDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInternetGatewayDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Detach if it is attached
|
// Detach if it is attached
|
||||||
if err := resourceAwsInternetGatewayDetach(d, meta); err != nil {
|
if err := resourceAwsInternetGatewayDetach(d, meta); err != nil {
|
||||||
|
@ -137,7 +137,7 @@ func resourceAwsInternetGatewayDelete(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
if d.Get("vpc_id").(string) == "" {
|
if d.Get("vpc_id").(string) == "" {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
|
@ -182,7 +182,7 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsInternetGatewayDetach(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsInternetGatewayDetach(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Get the old VPC ID to detach from
|
// Get the old VPC ID to detach from
|
||||||
vpcID, _ := d.GetChange("vpc_id")
|
vpcID, _ := d.GetChange("vpc_id")
|
||||||
|
|
|
@ -115,7 +115,7 @@ func TestAccInternetGateway_tags(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckInternetGatewayDestroy(s *terraform.State) error {
|
func testAccCheckInternetGatewayDestroy(s *terraform.State) error {
|
||||||
ec2conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_internet_gateway" {
|
if rs.Type != "aws_internet_gateway" {
|
||||||
|
@ -158,7 +158,7 @@ func testAccCheckInternetGatewayExists(n string, ig *ec2.InternetGateway) resour
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := ec2conn.DescribeInternetGateways(&ec2.DescribeInternetGatewaysRequest{
|
resp, err := ec2conn.DescribeInternetGateways(&ec2.DescribeInternetGatewaysRequest{
|
||||||
InternetGatewayIDs: []string{rs.Primary.ID},
|
InternetGatewayIDs: []string{rs.Primary.ID},
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,7 +37,7 @@ func resourceAwsKeyPair() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
keyName := d.Get("key_name").(string)
|
keyName := d.Get("key_name").(string)
|
||||||
publicKey := d.Get("public_key").(string)
|
publicKey := d.Get("public_key").(string)
|
||||||
|
@ -55,7 +55,7 @@ func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
req := &ec2.DescribeKeyPairsRequest{
|
req := &ec2.DescribeKeyPairsRequest{
|
||||||
KeyNames: []string{d.Id()},
|
KeyNames: []string{d.Id()},
|
||||||
|
@ -77,7 +77,7 @@ func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsKeyPairDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsKeyPairDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
err := ec2conn.DeleteKeyPair(&ec2.DeleteKeyPairRequest{
|
err := ec2conn.DeleteKeyPair(&ec2.DeleteKeyPairRequest{
|
||||||
KeyName: aws.String(d.Id()),
|
KeyName: aws.String(d.Id()),
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestAccAWSKeyPair_normal(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckAWSKeyPairDestroy(s *terraform.State) error {
|
func testAccCheckAWSKeyPairDestroy(s *terraform.State) error {
|
||||||
ec2conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_key_pair" {
|
if rs.Type != "aws_key_pair" {
|
||||||
|
@ -81,7 +81,7 @@ func testAccCheckAWSKeyPairExists(n string, res *ec2.KeyPairInfo) resource.TestC
|
||||||
return fmt.Errorf("No KeyPair name is set")
|
return fmt.Errorf("No KeyPair name is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
resp, err := ec2conn.DescribeKeyPairs(&ec2.DescribeKeyPairsRequest{
|
resp, err := ec2conn.DescribeKeyPairs(&ec2.DescribeKeyPairsRequest{
|
||||||
KeyNames: []string{rs.Primary.ID},
|
KeyNames: []string{rs.Primary.ID},
|
||||||
|
|
|
@ -40,7 +40,7 @@ func resourceAwsMainRouteTableAssociation() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsMainRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsMainRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
vpcId := d.Get("vpc_id").(string)
|
vpcId := d.Get("vpc_id").(string)
|
||||||
routeTableId := d.Get("route_table_id").(string)
|
routeTableId := d.Get("route_table_id").(string)
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func resourceAwsMainRouteTableAssociationCreate(d *schema.ResourceData, meta int
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
mainAssociation, err := findMainRouteTableAssociation(
|
mainAssociation, err := findMainRouteTableAssociation(
|
||||||
ec2conn,
|
ec2conn,
|
||||||
|
@ -88,7 +88,7 @@ func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta inter
|
||||||
// original_route_table_id - this needs to stay recorded as the AWS-created
|
// original_route_table_id - this needs to stay recorded as the AWS-created
|
||||||
// table from VPC creation.
|
// table from VPC creation.
|
||||||
func resourceAwsMainRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsMainRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
vpcId := d.Get("vpc_id").(string)
|
vpcId := d.Get("vpc_id").(string)
|
||||||
routeTableId := d.Get("route_table_id").(string)
|
routeTableId := d.Get("route_table_id").(string)
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ func resourceAwsMainRouteTableAssociationUpdate(d *schema.ResourceData, meta int
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsMainRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsMainRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
vpcId := d.Get("vpc_id").(string)
|
vpcId := d.Get("vpc_id").(string)
|
||||||
originalRouteTableId := d.Get("original_route_table_id").(string)
|
originalRouteTableId := d.Get("original_route_table_id").(string)
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ func testAccCheckMainRouteTableAssociation(
|
||||||
return fmt.Errorf("Not found: %s", vpcResource)
|
return fmt.Errorf("Not found: %s", vpcResource)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
mainAssociation, err := findMainRouteTableAssociation(conn, vpc.Primary.ID)
|
mainAssociation, err := findMainRouteTableAssociation(conn, vpc.Primary.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -109,7 +109,7 @@ func resourceAwsNetworkAcl() *schema.Resource {
|
||||||
|
|
||||||
func resourceAwsNetworkAclCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsNetworkAclCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Create the Network Acl
|
// Create the Network Acl
|
||||||
createOpts := &ec2.CreateNetworkACLRequest{
|
createOpts := &ec2.CreateNetworkACLRequest{
|
||||||
|
@ -132,7 +132,7 @@ func resourceAwsNetworkAclCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsNetworkAclRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsNetworkAclRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
resp, err := ec2conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
resp, err := ec2conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||||
NetworkACLIDs: []string{d.Id()},
|
NetworkACLIDs: []string{d.Id()},
|
||||||
|
@ -167,7 +167,7 @@ func resourceAwsNetworkAclRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsNetworkAclUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsNetworkAclUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
d.Partial(true)
|
d.Partial(true)
|
||||||
|
|
||||||
if d.HasChange("ingress") {
|
if d.HasChange("ingress") {
|
||||||
|
@ -265,7 +265,7 @@ func updateNetworkAclEntries(d *schema.ResourceData, entryType string, ec2conn *
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsNetworkAclDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsNetworkAclDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting Network Acl: %s", d.Id())
|
log.Printf("[INFO] Deleting Network Acl: %s", d.Id())
|
||||||
return resource.Retry(5*time.Minute, func() error {
|
return resource.Retry(5*time.Minute, func() error {
|
||||||
|
|
|
@ -184,7 +184,7 @@ func TestAccAWSNetworkAcl_SubnetChange(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckAWSNetworkAclDestroy(s *terraform.State) error {
|
func testAccCheckAWSNetworkAclDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_network" {
|
if rs.Type != "aws_network" {
|
||||||
|
@ -226,7 +226,7 @@ func testAccCheckAWSNetworkAclExists(n string, networkAcl *ec2.NetworkACL) resou
|
||||||
if rs.Primary.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No Security Group is set")
|
return fmt.Errorf("No Security Group is set")
|
||||||
}
|
}
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||||
NetworkACLIDs: []string{rs.Primary.ID},
|
NetworkACLIDs: []string{rs.Primary.ID},
|
||||||
|
@ -266,7 +266,7 @@ func testAccCheckSubnetIsAssociatedWithAcl(acl string, sub string) resource.Test
|
||||||
networkAcl := s.RootModule().Resources[acl]
|
networkAcl := s.RootModule().Resources[acl]
|
||||||
subnet := s.RootModule().Resources[sub]
|
subnet := s.RootModule().Resources[sub]
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||||
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
||||||
Filters: []ec2.Filter{
|
Filters: []ec2.Filter{
|
||||||
|
@ -296,7 +296,7 @@ func testAccCheckSubnetIsNotAssociatedWithAcl(acl string, subnet string) resourc
|
||||||
networkAcl := s.RootModule().Resources[acl]
|
networkAcl := s.RootModule().Resources[acl]
|
||||||
subnet := s.RootModule().Resources[subnet]
|
subnet := s.RootModule().Resources[subnet]
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||||
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
||||||
Filters: []ec2.Filter{
|
Filters: []ec2.Filter{
|
||||||
|
|
|
@ -62,7 +62,7 @@ func resourceAwsRouteTable() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Create the routing table
|
// Create the routing table
|
||||||
createOpts := &ec2.CreateRouteTableRequest{
|
createOpts := &ec2.CreateRouteTableRequest{
|
||||||
|
@ -100,7 +100,7 @@ func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id())()
|
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id())()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -152,7 +152,7 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Check if the route set as a whole has changed
|
// Check if the route set as a whole has changed
|
||||||
if d.HasChange("route") {
|
if d.HasChange("route") {
|
||||||
|
@ -213,7 +213,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// First request the routing table since we'll have to disassociate
|
// First request the routing table since we'll have to disassociate
|
||||||
// all the subnets first.
|
// all the subnets first.
|
||||||
|
|
|
@ -32,7 +32,7 @@ func resourceAwsRouteTableAssociation() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"[INFO] Creating route table association: %s => %s",
|
"[INFO] Creating route table association: %s => %s",
|
||||||
|
@ -56,7 +56,7 @@ func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interfa
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Get the routing table that this association belongs to
|
// Get the routing table that this association belongs to
|
||||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(
|
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(
|
||||||
|
@ -88,7 +88,7 @@ func resourceAwsRouteTableAssociationRead(d *schema.ResourceData, meta interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"[INFO] Creating route table association: %s => %s",
|
"[INFO] Creating route table association: %s => %s",
|
||||||
|
@ -119,7 +119,7 @@ func resourceAwsRouteTableAssociationUpdate(d *schema.ResourceData, meta interfa
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting route table association: %s", d.Id())
|
log.Printf("[INFO] Deleting route table association: %s", d.Id())
|
||||||
err := ec2conn.DisassociateRouteTable(&ec2.DisassociateRouteTableRequest{
|
err := ec2conn.DisassociateRouteTable(&ec2.DisassociateRouteTableRequest{
|
||||||
|
|
|
@ -38,7 +38,7 @@ func TestAccAWSRouteTableAssociation(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckRouteTableAssociationDestroy(s *terraform.State) error {
|
func testAccCheckRouteTableAssociationDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_route_table_association" {
|
if rs.Type != "aws_route_table_association" {
|
||||||
|
@ -83,7 +83,7 @@ func testAccCheckRouteTableAssociationExists(n string, v *ec2.RouteTable) resour
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||||
RouteTableIDs: []string{rs.Primary.Attributes["route_table_id"]},
|
RouteTableIDs: []string{rs.Primary.Attributes["route_table_id"]},
|
||||||
})
|
})
|
||||||
|
|
|
@ -151,7 +151,7 @@ func TestAccAWSRouteTable_tags(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckRouteTableDestroy(s *terraform.State) error {
|
func testAccCheckRouteTableDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_route_table" {
|
if rs.Type != "aws_route_table" {
|
||||||
|
@ -194,7 +194,7 @@ func testAccCheckRouteTableExists(n string, v *ec2.RouteTable) resource.TestChec
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||||
RouteTableIDs: []string{rs.Primary.ID},
|
RouteTableIDs: []string{rs.Primary.ID},
|
||||||
})
|
})
|
||||||
|
|
|
@ -142,7 +142,7 @@ func resourceAwsSecurityGroup() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
securityGroupOpts := &ec2.CreateSecurityGroupRequest{
|
securityGroupOpts := &ec2.CreateSecurityGroupRequest{
|
||||||
GroupName: aws.String(d.Get("name").(string)),
|
GroupName: aws.String(d.Get("name").(string)),
|
||||||
|
@ -187,7 +187,7 @@ func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
sgRaw, _, err := SGStateRefreshFunc(ec2conn, d.Id())()
|
sgRaw, _, err := SGStateRefreshFunc(ec2conn, d.Id())()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -214,7 +214,7 @@ func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
sgRaw, _, err := SGStateRefreshFunc(ec2conn, d.Id())()
|
sgRaw, _, err := SGStateRefreshFunc(ec2conn, d.Id())()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -249,7 +249,7 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf("[DEBUG] Security Group destroy: %v", d.Id())
|
log.Printf("[DEBUG] Security Group destroy: %v", d.Id())
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ func resourceAwsSecurityGroupIPPermGather(d *schema.ResourceData, permissions []
|
||||||
|
|
||||||
var groups []string
|
var groups []string
|
||||||
if len(perm.UserIDGroupPairs) > 0 {
|
if len(perm.UserIDGroupPairs) > 0 {
|
||||||
groups = flattenSecurityGroupsSDK(perm.UserIDGroupPairs)
|
groups = flattenSecurityGroups(perm.UserIDGroupPairs)
|
||||||
}
|
}
|
||||||
for i, id := range groups {
|
for i, id := range groups {
|
||||||
if id == d.Id() {
|
if id == d.Id() {
|
||||||
|
@ -396,7 +396,6 @@ func resourceAwsSecurityGroupUpdateRules(
|
||||||
os := o.(*schema.Set)
|
os := o.(*schema.Set)
|
||||||
ns := n.(*schema.Set)
|
ns := n.(*schema.Set)
|
||||||
|
|
||||||
// TODO: re-munge this when test is updated
|
|
||||||
remove := expandIPPerms(d.Id(), os.Difference(ns).List())
|
remove := expandIPPerms(d.Id(), os.Difference(ns).List())
|
||||||
add := expandIPPerms(d.Id(), ns.Difference(os).List())
|
add := expandIPPerms(d.Id(), ns.Difference(os).List())
|
||||||
|
|
||||||
|
@ -410,7 +409,7 @@ func resourceAwsSecurityGroupUpdateRules(
|
||||||
// not have service issues.
|
// not have service issues.
|
||||||
|
|
||||||
if len(remove) > 0 || len(add) > 0 {
|
if len(remove) > 0 || len(add) > 0 {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if len(remove) > 0 {
|
if len(remove) > 0 {
|
||||||
|
|
|
@ -186,7 +186,7 @@ func TestAccAWSSecurityGroup_Change(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckAWSSecurityGroupDestroy(s *terraform.State) error {
|
func testAccCheckAWSSecurityGroupDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_security_group" {
|
if rs.Type != "aws_security_group" {
|
||||||
|
@ -230,7 +230,7 @@ func testAccCheckAWSSecurityGroupExists(n string, group *ec2.SecurityGroup) reso
|
||||||
return fmt.Errorf("No Security Group is set")
|
return fmt.Errorf("No Security Group is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
req := &ec2.DescribeSecurityGroupsRequest{
|
req := &ec2.DescribeSecurityGroupsRequest{
|
||||||
GroupIDs: []string{rs.Primary.ID},
|
GroupIDs: []string{rs.Primary.ID},
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func resourceAwsSubnet() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
createOpts := &ec2.CreateSubnetRequest{
|
createOpts := &ec2.CreateSubnetRequest{
|
||||||
AvailabilityZone: aws.String(d.Get("availability_zone").(string)),
|
AvailabilityZone: aws.String(d.Get("availability_zone").(string)),
|
||||||
|
@ -91,7 +91,7 @@ func resourceAwsSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
resp, err := ec2conn.DescribeSubnets(&ec2.DescribeSubnetsRequest{
|
resp, err := ec2conn.DescribeSubnets(&ec2.DescribeSubnetsRequest{
|
||||||
SubnetIDs: []string{d.Id()},
|
SubnetIDs: []string{d.Id()},
|
||||||
|
@ -121,7 +121,7 @@ func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
d.Partial(true)
|
d.Partial(true)
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsSubnetDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsSubnetDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting subnet: %s", d.Id())
|
log.Printf("[INFO] Deleting subnet: %s", d.Id())
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestAccAWSSubnet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckSubnetDestroy(s *terraform.State) error {
|
func testAccCheckSubnetDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_subnet" {
|
if rs.Type != "aws_subnet" {
|
||||||
|
@ -86,7 +86,7 @@ func testAccCheckSubnetExists(n string, v *ec2.Subnet) resource.TestCheckFunc {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
resp, err := conn.DescribeSubnets(&ec2.DescribeSubnetsRequest{
|
resp, err := conn.DescribeSubnets(&ec2.DescribeSubnetsRequest{
|
||||||
SubnetIDs: []string{rs.Primary.ID},
|
SubnetIDs: []string{rs.Primary.ID},
|
||||||
})
|
})
|
||||||
|
|
|
@ -64,7 +64,7 @@ func resourceAwsVpc() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
instance_tenancy := "default"
|
instance_tenancy := "default"
|
||||||
if v, ok := d.GetOk("instance_tenancy"); ok {
|
if v, ok := d.GetOk("instance_tenancy"); ok {
|
||||||
instance_tenancy = v.(string)
|
instance_tenancy = v.(string)
|
||||||
|
@ -110,7 +110,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Refresh the VPC state
|
// Refresh the VPC state
|
||||||
vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())()
|
vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())()
|
||||||
|
@ -180,7 +180,7 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Turn on partial mode
|
// Turn on partial mode
|
||||||
d.Partial(true)
|
d.Partial(true)
|
||||||
|
@ -231,7 +231,7 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
vpcID := d.Id()
|
vpcID := d.Id()
|
||||||
DeleteVpcOpts := &ec2.DeleteVPCRequest{
|
DeleteVpcOpts := &ec2.DeleteVPCRequest{
|
||||||
VPCID: &vpcID,
|
VPCID: &vpcID,
|
||||||
|
|
|
@ -41,7 +41,7 @@ func resourceAwsVpcPeeringConnection() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
// Create the vpc peering connection
|
// Create the vpc peering connection
|
||||||
createOpts := &ec2.CreateVPCPeeringConnectionRequest{
|
createOpts := &ec2.CreateVPCPeeringConnectionRequest{
|
||||||
|
@ -80,7 +80,7 @@ func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
pcRaw, _, err := resourceAwsVpcPeeringConnectionStateRefreshFunc(ec2conn, d.Id())()
|
pcRaw, _, err := resourceAwsVpcPeeringConnectionStateRefreshFunc(ec2conn, d.Id())()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -101,7 +101,7 @@ func resourceAwsVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcPeeringUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcPeeringUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
if err := setTags(ec2conn, d); err != nil {
|
if err := setTags(ec2conn, d); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -113,7 +113,7 @@ func resourceAwsVpcPeeringUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsVpcPeeringDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVpcPeeringDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
ec2conn := meta.(*AWSClient).ec2conn
|
||||||
|
|
||||||
_, err := ec2conn.DeleteVPCPeeringConnection(
|
_, err := ec2conn.DeleteVPCPeeringConnection(
|
||||||
&ec2.DeleteVPCPeeringConnectionRequest{
|
&ec2.DeleteVPCPeeringConnectionRequest{
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestAccAWSVPCPeeringConnection_normal(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
|
func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_vpc_peering_connection" {
|
if rs.Type != "aws_vpc_peering_connection" {
|
||||||
|
|
|
@ -111,7 +111,7 @@ func TestAccVpcUpdate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckVpcDestroy(s *terraform.State) error {
|
func testAccCheckVpcDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "aws_vpc" {
|
if rs.Type != "aws_vpc" {
|
||||||
|
@ -166,7 +166,7 @@ func testAccCheckVpcExists(n string, vpc *ec2.VPC) resource.TestCheckFunc {
|
||||||
return fmt.Errorf("No VPC ID is set")
|
return fmt.Errorf("No VPC ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||||
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
||||||
VPCIDs: []string{rs.Primary.ID},
|
VPCIDs: []string{rs.Primary.ID},
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,16 +129,7 @@ func flattenHealthCheck(check *elb.HealthCheck) []map[string]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flattens an array of UserSecurityGroups into a []string
|
// Flattens an array of UserSecurityGroups into a []string
|
||||||
func flattenSecurityGroups(list []ec2.UserSecurityGroup) []string {
|
func flattenSecurityGroups(list []ec2.UserIDGroupPair) []string {
|
||||||
result := make([]string, 0, len(list))
|
|
||||||
for _, g := range list {
|
|
||||||
result = append(result, g.Id)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flattens an array of UserSecurityGroups into a []string
|
|
||||||
func flattenSecurityGroupsSDK(list []ec2.UserIDGroupPair) []string {
|
|
||||||
result := make([]string, 0, len(list))
|
result := make([]string, 0, len(list))
|
||||||
for _, g := range list {
|
for _, g := range list {
|
||||||
result = append(result, *g.GroupID)
|
result = append(result, *g.GroupID)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/aws-sdk-go/aws"
|
"github.com/hashicorp/aws-sdk-go/aws"
|
||||||
awsEC2 "github.com/hashicorp/aws-sdk-go/gen/ec2"
|
ec2 "github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||||
"github.com/hashicorp/terraform/flatmap"
|
"github.com/hashicorp/terraform/flatmap"
|
||||||
|
@ -61,28 +61,28 @@ func TestExpandIPPerms(t *testing.T) {
|
||||||
}
|
}
|
||||||
perms := expandIPPerms("foo", expanded)
|
perms := expandIPPerms("foo", expanded)
|
||||||
|
|
||||||
expected := []awsEC2.IPPermission{
|
expected := []ec2.IPPermission{
|
||||||
awsEC2.IPPermission{
|
ec2.IPPermission{
|
||||||
IPProtocol: aws.String("icmp"),
|
IPProtocol: aws.String("icmp"),
|
||||||
FromPort: aws.Integer(1),
|
FromPort: aws.Integer(1),
|
||||||
ToPort: aws.Integer(-1),
|
ToPort: aws.Integer(-1),
|
||||||
IPRanges: []awsEC2.IPRange{awsEC2.IPRange{aws.String("0.0.0.0/0")}},
|
IPRanges: []ec2.IPRange{ec2.IPRange{aws.String("0.0.0.0/0")}},
|
||||||
UserIDGroupPairs: []awsEC2.UserIDGroupPair{
|
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||||
awsEC2.UserIDGroupPair{
|
ec2.UserIDGroupPair{
|
||||||
UserID: aws.String("foo"),
|
UserID: aws.String("foo"),
|
||||||
GroupID: aws.String("sg-22222"),
|
GroupID: aws.String("sg-22222"),
|
||||||
},
|
},
|
||||||
awsEC2.UserIDGroupPair{
|
ec2.UserIDGroupPair{
|
||||||
GroupID: aws.String("sg-22222"),
|
GroupID: aws.String("sg-22222"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
awsEC2.IPPermission{
|
ec2.IPPermission{
|
||||||
IPProtocol: aws.String("icmp"),
|
IPProtocol: aws.String("icmp"),
|
||||||
FromPort: aws.Integer(1),
|
FromPort: aws.Integer(1),
|
||||||
ToPort: aws.Integer(-1),
|
ToPort: aws.Integer(-1),
|
||||||
UserIDGroupPairs: []awsEC2.UserIDGroupPair{
|
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||||
awsEC2.UserIDGroupPair{
|
ec2.UserIDGroupPair{
|
||||||
UserID: aws.String("foo"),
|
UserID: aws.String("foo"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue