Merge remote-tracking branch 'refs/remotes/origin/master' into route53-zone-nameservers
This commit is contained in:
commit
c3f9c12426
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -1,3 +1,26 @@
|
|||
## 0.5.0 (unreleased)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* **New config function: `length`** - Get the length of a string or a list.
|
||||
Useful in conjunction with `split`. [GH-1495]
|
||||
* core: Improve error message on diff mismatch [GH-1501]
|
||||
* provisioner/file: expand `~` in source path [GH-1569]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
* core: math on arbitrary variables works if first operand isn't a
|
||||
numeric primitive. [GH-1381]
|
||||
* core: avoid unnecessary cycles by pruning tainted destroys from
|
||||
graph if there are no tainted resources [GH-1475]
|
||||
* core: fix issue where destroy nodes weren't pruned in specific
|
||||
edge cases around matching prefixes, which could cause cycles [GH-1527]
|
||||
* core: fix issue causing diff mismatch errors in certain scenarios during
|
||||
resource replacement [GH-1515]
|
||||
* command: remote states with uppercase types work [GH-1356]
|
||||
* provider/aws: launch configuration ID set after create success [GH-1518]
|
||||
* provider/openstack: region config is not required [GH-1441]
|
||||
|
||||
## 0.4.2 (April 10, 2015)
|
||||
|
||||
BUG FIXES:
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -61,23 +61,23 @@ func setAutoscalingTags(conn *autoscaling.AutoScaling, d *schema.ResourceData) e
|
|||
autoscalingTagsFromMap(o, resourceID),
|
||||
autoscalingTagsFromMap(n, resourceID),
|
||||
resourceID)
|
||||
create := autoscaling.CreateOrUpdateTagsType{
|
||||
create := autoscaling.CreateOrUpdateTagsInput{
|
||||
Tags: c,
|
||||
}
|
||||
remove := autoscaling.DeleteTagsType{
|
||||
remove := autoscaling.DeleteTagsInput{
|
||||
Tags: r,
|
||||
}
|
||||
|
||||
// Set tags
|
||||
if len(r) > 0 {
|
||||
log.Printf("[DEBUG] Removing autoscaling tags: %#v", r)
|
||||
if err := conn.DeleteTags(&remove); err != nil {
|
||||
if _, err := conn.DeleteTags(&remove); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(c) > 0 {
|
||||
log.Printf("[DEBUG] Creating autoscaling tags: %#v", c)
|
||||
if err := conn.CreateOrUpdateTags(&create); err != nil {
|
||||
if _, err := conn.CreateOrUpdateTags(&create); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func setAutoscalingTags(conn *autoscaling.AutoScaling, d *schema.ResourceData) e
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffAutoscalingTags(oldTags, newTags []autoscaling.Tag, resourceID string) ([]autoscaling.Tag, []autoscaling.Tag) {
|
||||
func diffAutoscalingTags(oldTags, newTags []*autoscaling.Tag, resourceID string) ([]*autoscaling.Tag, []*autoscaling.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -101,7 +101,7 @@ func diffAutoscalingTags(oldTags, newTags []autoscaling.Tag, resourceID string)
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []autoscaling.Tag
|
||||
var remove []*autoscaling.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key].(map[string]interface{})
|
||||
|
||||
|
@ -115,11 +115,11 @@ func diffAutoscalingTags(oldTags, newTags []autoscaling.Tag, resourceID string)
|
|||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func autoscalingTagsFromMap(m map[string]interface{}, resourceID string) []autoscaling.Tag {
|
||||
result := make([]autoscaling.Tag, 0, len(m))
|
||||
func autoscalingTagsFromMap(m map[string]interface{}, resourceID string) []*autoscaling.Tag {
|
||||
result := make([]*autoscaling.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
attr := v.(map[string]interface{})
|
||||
result = append(result, autoscaling.Tag{
|
||||
result = append(result, &autoscaling.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(attr["value"].(string)),
|
||||
PropagateAtLaunch: aws.Boolean(attr["propagate_at_launch"].(bool)),
|
||||
|
@ -132,7 +132,7 @@ func autoscalingTagsFromMap(m map[string]interface{}, resourceID string) []autos
|
|||
}
|
||||
|
||||
// autoscalingTagsToMap turns the list of tags into a map.
|
||||
func autoscalingTagsToMap(ts []autoscaling.Tag) map[string]interface{} {
|
||||
func autoscalingTagsToMap(ts []*autoscaling.Tag) map[string]interface{} {
|
||||
tags := make(map[string]interface{})
|
||||
for _, t := range ts {
|
||||
tag := map[string]interface{}{
|
||||
|
@ -146,9 +146,9 @@ func autoscalingTagsToMap(ts []autoscaling.Tag) map[string]interface{} {
|
|||
}
|
||||
|
||||
// autoscalingTagDescriptionsToMap turns the list of tags into a map.
|
||||
func autoscalingTagDescriptionsToMap(ts []autoscaling.TagDescription) map[string]map[string]interface{} {
|
||||
func autoscalingTagDescriptionsToMap(ts *[]*autoscaling.TagDescription) map[string]map[string]interface{} {
|
||||
tags := make(map[string]map[string]interface{})
|
||||
for _, t := range ts {
|
||||
for _, t := range *ts {
|
||||
tag := map[string]interface{}{
|
||||
"value": *t.Value,
|
||||
"propagate_at_launch": *t.PropagateAtLaunch,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -93,9 +93,9 @@ func TestDiffAutoscalingTags(t *testing.T) {
|
|||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckAutoscalingTags(
|
||||
ts *[]autoscaling.TagDescription, key string, expected map[string]interface{}) resource.TestCheckFunc {
|
||||
ts *[]*autoscaling.TagDescription, key string, expected map[string]interface{}) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := autoscalingTagDescriptionsToMap(*ts)
|
||||
m := autoscalingTagDescriptionsToMap(ts)
|
||||
v, ok := m[key]
|
||||
if !ok {
|
||||
return fmt.Errorf("Missing tag: %s", key)
|
||||
|
@ -110,9 +110,9 @@ func testAccCheckAutoscalingTags(
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckAutoscalingTagNotExists(ts *[]autoscaling.TagDescription, key string) resource.TestCheckFunc {
|
||||
func testAccCheckAutoscalingTagNotExists(ts *[]*autoscaling.TagDescription, key string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := autoscalingTagDescriptionsToMap(*ts)
|
||||
m := autoscalingTagDescriptionsToMap(ts)
|
||||
if _, ok := m[key]; ok {
|
||||
return fmt.Errorf("Tag exists when it should not: %s", key)
|
||||
}
|
||||
|
|
|
@ -6,17 +6,14 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/multierror"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/iam"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/s3"
|
||||
|
||||
awsSDK "github.com/awslabs/aws-sdk-go/aws"
|
||||
awsEC2 "github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -35,7 +32,6 @@ type AWSClient struct {
|
|||
region string
|
||||
rdsconn *rds.RDS
|
||||
iamconn *iam.IAM
|
||||
ec2SDKconn *awsEC2.EC2
|
||||
}
|
||||
|
||||
// Client configures and returns a fully initailized AWSClient
|
||||
|
@ -59,30 +55,37 @@ func (c *Config) Client() (interface{}, error) {
|
|||
|
||||
log.Println("[INFO] Building AWS auth structure")
|
||||
creds := aws.DetectCreds(c.AccessKey, c.SecretKey, c.Token)
|
||||
awsConfig := &aws.Config{
|
||||
Credentials: creds,
|
||||
Region: c.Region,
|
||||
}
|
||||
|
||||
log.Println("[INFO] Initializing ELB connection")
|
||||
client.elbconn = elb.New(creds, c.Region, nil)
|
||||
log.Println("[INFO] Initializing AutoScaling connection")
|
||||
client.autoscalingconn = autoscaling.New(creds, c.Region, nil)
|
||||
client.elbconn = elb.New(awsConfig)
|
||||
|
||||
log.Println("[INFO] Initializing S3 connection")
|
||||
client.s3conn = s3.New(creds, c.Region, nil)
|
||||
log.Println("[INFO] Initializing RDS connection")
|
||||
client.rdsconn = rds.New(creds, c.Region, nil)
|
||||
client.s3conn = s3.New(awsConfig)
|
||||
|
||||
log.Println("[INFO] Initializing RDS Connection")
|
||||
client.rdsconn = rds.New(awsConfig)
|
||||
|
||||
log.Println("[INFO] Initializing IAM Connection")
|
||||
client.iamconn = iam.New(awsConfig)
|
||||
log.Println("[INFO] Initializing AutoScaling connection")
|
||||
client.autoscalingconn = autoscaling.New(awsConfig)
|
||||
|
||||
log.Println("[INFO] Initializing EC2 Connection")
|
||||
client.ec2conn = ec2.New(awsConfig)
|
||||
|
||||
// aws-sdk-go uses v4 for signing requests, which requires all global
|
||||
// endpoints to use 'us-east-1'.
|
||||
// See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
|
||||
log.Println("[INFO] Initializing Route53 connection")
|
||||
client.r53conn = route53.New(creds, "us-east-1", nil)
|
||||
log.Println("[INFO] Initializing EC2 Connection")
|
||||
client.ec2conn = ec2.New(creds, c.Region, nil)
|
||||
client.iamconn = iam.New(creds, c.Region, nil)
|
||||
|
||||
sdkCreds := awsSDK.DetectCreds(c.AccessKey, c.SecretKey, c.Token)
|
||||
client.ec2SDKconn = awsEC2.New(&awsSDK.Config{
|
||||
Credentials: sdkCreds,
|
||||
Region: c.Region,
|
||||
log.Println("[INFO] Initializing Route 53 connection")
|
||||
client.r53conn = route53.New(&aws.Config{
|
||||
Credentials: creds,
|
||||
Region: "us-east-1",
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
)
|
||||
|
||||
func resourceAwsAutoscalingGroup() *schema.Resource {
|
||||
|
@ -127,11 +127,11 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
|||
func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
|
||||
var autoScalingGroupOpts autoscaling.CreateAutoScalingGroupType
|
||||
var autoScalingGroupOpts autoscaling.CreateAutoScalingGroupInput
|
||||
autoScalingGroupOpts.AutoScalingGroupName = aws.String(d.Get("name").(string))
|
||||
autoScalingGroupOpts.LaunchConfigurationName = aws.String(d.Get("launch_configuration").(string))
|
||||
autoScalingGroupOpts.MinSize = aws.Integer(d.Get("min_size").(int))
|
||||
autoScalingGroupOpts.MaxSize = aws.Integer(d.Get("max_size").(int))
|
||||
autoScalingGroupOpts.MinSize = aws.Long(int64(d.Get("min_size").(int)))
|
||||
autoScalingGroupOpts.MaxSize = aws.Long(int64(d.Get("max_size").(int)))
|
||||
autoScalingGroupOpts.AvailabilityZones = expandStringList(
|
||||
d.Get("availability_zones").(*schema.Set).List())
|
||||
|
||||
|
@ -141,7 +141,7 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
if v, ok := d.GetOk("default_cooldown"); ok {
|
||||
autoScalingGroupOpts.DefaultCooldown = aws.Integer(v.(int))
|
||||
autoScalingGroupOpts.DefaultCooldown = aws.Long(int64(v.(int)))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("health_check_type"); ok && v.(string) != "" {
|
||||
|
@ -149,11 +149,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
if v, ok := d.GetOk("desired_capacity"); ok {
|
||||
autoScalingGroupOpts.DesiredCapacity = aws.Integer(v.(int))
|
||||
autoScalingGroupOpts.DesiredCapacity = aws.Long(int64(v.(int)))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("health_check_grace_period"); ok {
|
||||
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Integer(v.(int))
|
||||
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Long(int64(v.(int)))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
|
||||
|
@ -163,7 +163,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
|
||||
if v, ok := d.GetOk("vpc_zone_identifier"); ok && v.(*schema.Set).Len() > 0 {
|
||||
exp := expandStringList(v.(*schema.Set).List())
|
||||
autoScalingGroupOpts.VPCZoneIdentifier = aws.String(strings.Join(exp, ","))
|
||||
strs := make([]string, len(exp))
|
||||
for _, s := range exp {
|
||||
strs = append(strs, *s)
|
||||
}
|
||||
autoScalingGroupOpts.VPCZoneIdentifier = aws.String(strings.Join(strs, ","))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("termination_policies"); ok && v.(*schema.Set).Len() > 0 {
|
||||
|
@ -172,7 +176,7 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", autoScalingGroupOpts)
|
||||
err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts)
|
||||
_, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating Autoscaling Group: %s", err)
|
||||
}
|
||||
|
@ -212,12 +216,12 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e
|
|||
func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
|
||||
opts := autoscaling.UpdateAutoScalingGroupType{
|
||||
opts := autoscaling.UpdateAutoScalingGroupInput{
|
||||
AutoScalingGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
if d.HasChange("desired_capacity") {
|
||||
opts.DesiredCapacity = aws.Integer(d.Get("desired_capacity").(int))
|
||||
opts.DesiredCapacity = aws.Long(int64(d.Get("desired_capacity").(int)))
|
||||
}
|
||||
|
||||
if d.HasChange("launch_configuration") {
|
||||
|
@ -225,11 +229,11 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
if d.HasChange("min_size") {
|
||||
opts.MinSize = aws.Integer(d.Get("min_size").(int))
|
||||
opts.MinSize = aws.Long(int64(d.Get("min_size").(int)))
|
||||
}
|
||||
|
||||
if d.HasChange("max_size") {
|
||||
opts.MaxSize = aws.Integer(d.Get("max_size").(int))
|
||||
opts.MaxSize = aws.Long(int64(d.Get("max_size").(int)))
|
||||
}
|
||||
|
||||
if err := setAutoscalingTags(autoscalingconn, d); err != nil {
|
||||
|
@ -239,7 +243,7 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
log.Printf("[DEBUG] AutoScaling Group update configuration: %#v", opts)
|
||||
err := autoscalingconn.UpdateAutoScalingGroup(&opts)
|
||||
_, err := autoscalingconn.UpdateAutoScalingGroup(&opts)
|
||||
if err != nil {
|
||||
d.Partial(true)
|
||||
return fmt.Errorf("Error updating Autoscaling group: %s", err)
|
||||
|
@ -268,7 +272,7 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
log.Printf("[DEBUG] AutoScaling Group destroy: %v", d.Id())
|
||||
deleteopts := autoscaling.DeleteAutoScalingGroupType{AutoScalingGroupName: aws.String(d.Id())}
|
||||
deleteopts := autoscaling.DeleteAutoScalingGroupInput{AutoScalingGroupName: aws.String(d.Id())}
|
||||
|
||||
// You can force an autoscaling group to delete
|
||||
// even if it's in the process of scaling a resource.
|
||||
|
@ -279,7 +283,7 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{})
|
|||
deleteopts.ForceDelete = aws.Boolean(true)
|
||||
}
|
||||
|
||||
if err := autoscalingconn.DeleteAutoScalingGroup(&deleteopts); err != nil {
|
||||
if _, err := autoscalingconn.DeleteAutoScalingGroup(&deleteopts); err != nil {
|
||||
autoscalingerr, ok := err.(aws.APIError)
|
||||
if ok && autoscalingerr.Code == "InvalidGroup.NotFound" {
|
||||
return nil
|
||||
|
@ -300,8 +304,8 @@ func getAwsAutoscalingGroup(
|
|||
meta interface{}) (*autoscaling.AutoScalingGroup, error) {
|
||||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
|
||||
describeOpts := autoscaling.AutoScalingGroupNamesType{
|
||||
AutoScalingGroupNames: []string{d.Id()},
|
||||
describeOpts := autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String(d.Id())},
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] AutoScaling Group describe configuration: %#v", describeOpts)
|
||||
|
@ -319,7 +323,7 @@ func getAwsAutoscalingGroup(
|
|||
// Search for the autoscaling group
|
||||
for idx, asc := range describeGroups.AutoScalingGroups {
|
||||
if *asc.AutoScalingGroupName == d.Id() {
|
||||
return &describeGroups.AutoScalingGroups[idx], nil
|
||||
return describeGroups.AutoScalingGroups[idx], nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,13 +337,13 @@ func resourceAwsAutoscalingGroupDrain(d *schema.ResourceData, meta interface{})
|
|||
|
||||
// First, set the capacity to zero so the group will drain
|
||||
log.Printf("[DEBUG] Reducing autoscaling group capacity to zero")
|
||||
opts := autoscaling.UpdateAutoScalingGroupType{
|
||||
opts := autoscaling.UpdateAutoScalingGroupInput{
|
||||
AutoScalingGroupName: aws.String(d.Id()),
|
||||
DesiredCapacity: aws.Integer(0),
|
||||
MinSize: aws.Integer(0),
|
||||
MaxSize: aws.Integer(0),
|
||||
DesiredCapacity: aws.Long(0),
|
||||
MinSize: aws.Long(0),
|
||||
MaxSize: aws.Long(0),
|
||||
}
|
||||
if err := autoscalingconn.UpdateAutoScalingGroup(&opts); err != nil {
|
||||
if _, err := autoscalingconn.UpdateAutoScalingGroup(&opts); err != nil {
|
||||
return fmt.Errorf("Error setting capacity to zero to drain: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -98,7 +98,7 @@ func TestAccAWSAutoScalingGroup_tags(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSAutoScalingGroupWithLoadBalancer(t *testing.T) {
|
||||
func TestAccAWSAutoScalingGroup_WithLoadBalancer(t *testing.T) {
|
||||
var group autoscaling.AutoScalingGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
@ -126,8 +126,8 @@ func testAccCheckAWSAutoScalingGroupDestroy(s *terraform.State) error {
|
|||
|
||||
// Try to find the Group
|
||||
describeGroups, err := conn.DescribeAutoScalingGroups(
|
||||
&autoscaling.AutoScalingGroupNamesType{
|
||||
AutoScalingGroupNames: []string{rs.Primary.ID},
|
||||
&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
@ -152,8 +152,8 @@ func testAccCheckAWSAutoScalingGroupDestroy(s *terraform.State) error {
|
|||
|
||||
func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if group.AvailabilityZones[0] != "us-west-2a" {
|
||||
return fmt.Errorf("Bad availability_zones: %s", group.AvailabilityZones[0])
|
||||
if *group.AvailabilityZones[0] != "us-west-2a" {
|
||||
return fmt.Errorf("Bad availability_zones: %#v", group.AvailabilityZones[0])
|
||||
}
|
||||
|
||||
if *group.AutoScalingGroupName != "foobar3-terraform-test" {
|
||||
|
@ -184,7 +184,7 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro
|
|||
return fmt.Errorf("Bad launch configuration name: %s", *group.LaunchConfigurationName)
|
||||
}
|
||||
|
||||
t := autoscaling.TagDescription{
|
||||
t := &autoscaling.TagDescription{
|
||||
Key: aws.String("Foo"),
|
||||
Value: aws.String("foo-bar"),
|
||||
PropagateAtLaunch: aws.Boolean(true),
|
||||
|
@ -205,8 +205,8 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro
|
|||
|
||||
func testAccCheckAWSAutoScalingGroupAttributesLoadBalancer(group *autoscaling.AutoScalingGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if group.LoadBalancerNames[0] != "foobar-terraform-test" {
|
||||
return fmt.Errorf("Bad load_balancers: %s", group.LoadBalancerNames[0])
|
||||
if *group.LoadBalancerNames[0] != "foobar-terraform-test" {
|
||||
return fmt.Errorf("Bad load_balancers: %#v", group.LoadBalancerNames[0])
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -226,10 +226,10 @@ func testAccCheckAWSAutoScalingGroupExists(n string, group *autoscaling.AutoScal
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).autoscalingconn
|
||||
|
||||
describeOpts := autoscaling.AutoScalingGroupNamesType{
|
||||
AutoScalingGroupNames: []string{rs.Primary.ID},
|
||||
}
|
||||
describeGroups, err := conn.DescribeAutoScalingGroups(&describeOpts)
|
||||
describeGroups, err := conn.DescribeAutoScalingGroups(
|
||||
&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -240,7 +240,7 @@ func testAccCheckAWSAutoScalingGroupExists(n string, group *autoscaling.AutoScal
|
|||
return fmt.Errorf("AutoScaling Group not found")
|
||||
}
|
||||
|
||||
*group = describeGroups.AutoScalingGroups[0]
|
||||
*group = *describeGroups.AutoScalingGroups[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/iam"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
|
@ -196,8 +196,8 @@ func resourceAwsDbInstance() *schema.Resource {
|
|||
func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
tags := tagsFromMapRDS(d.Get("tags").(map[string]interface{}))
|
||||
opts := rds.CreateDBInstanceMessage{
|
||||
AllocatedStorage: aws.Integer(d.Get("allocated_storage").(int)),
|
||||
opts := rds.CreateDBInstanceInput{
|
||||
AllocatedStorage: aws.Long(int64(d.Get("allocated_storage").(int))),
|
||||
DBInstanceClass: aws.String(d.Get("instance_class").(string)),
|
||||
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
|
||||
DBName: aws.String(d.Get("name").(string)),
|
||||
|
@ -214,14 +214,14 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
attr := d.Get("backup_retention_period")
|
||||
opts.BackupRetentionPeriod = aws.Integer(attr.(int))
|
||||
opts.BackupRetentionPeriod = aws.Long(int64(attr.(int)))
|
||||
|
||||
if attr, ok := d.GetOk("iops"); ok {
|
||||
opts.IOPS = aws.Integer(attr.(int))
|
||||
opts.IOPS = aws.Long(int64(attr.(int)))
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("port"); ok {
|
||||
opts.Port = aws.Integer(attr.(int))
|
||||
opts.Port = aws.Long(int64(attr.(int)))
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("multi_az"); ok {
|
||||
|
@ -253,17 +253,17 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 {
|
||||
var s []string
|
||||
var s []*string
|
||||
for _, v := range attr.List() {
|
||||
s = append(s, v.(string))
|
||||
s = append(s, aws.String(v.(string)))
|
||||
}
|
||||
opts.VPCSecurityGroupIDs = s
|
||||
}
|
||||
|
||||
if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 {
|
||||
var s []string
|
||||
var s []*string
|
||||
for _, v := range attr.List() {
|
||||
s = append(s, v.(string))
|
||||
s = append(s, aws.String(v.(string)))
|
||||
}
|
||||
opts.DBSecurityGroups = s
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
log.Printf("[DEBUG] Error building ARN for DB Instance, not setting Tags for DB %s", name)
|
||||
} else {
|
||||
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceMessage{
|
||||
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
|
||||
ResourceName: aws.String(arn),
|
||||
})
|
||||
|
||||
|
@ -363,7 +363,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[DEBUG] Error retreiving tags for ARN: %s", arn)
|
||||
}
|
||||
|
||||
var dt []rds.Tag
|
||||
var dt []*rds.Tag
|
||||
if len(resp.TagList) > 0 {
|
||||
dt = resp.TagList
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
log.Printf("[DEBUG] DB Instance destroy: %v", d.Id())
|
||||
|
||||
opts := rds.DeleteDBInstanceMessage{DBInstanceIdentifier: aws.String(d.Id())}
|
||||
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
|
||||
|
||||
finalSnapshot := d.Get("final_snapshot_identifier").(string)
|
||||
if finalSnapshot == "" {
|
||||
|
@ -437,7 +437,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
d.Partial(true)
|
||||
|
||||
req := &rds.ModifyDBInstanceMessage{
|
||||
req := &rds.ModifyDBInstanceInput{
|
||||
ApplyImmediately: aws.Boolean(d.Get("apply_immediately").(bool)),
|
||||
DBInstanceIdentifier: aws.String(d.Id()),
|
||||
}
|
||||
|
@ -445,11 +445,11 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
if d.HasChange("allocated_storage") {
|
||||
d.SetPartial("allocated_storage")
|
||||
req.AllocatedStorage = aws.Integer(d.Get("allocated_storage").(int))
|
||||
req.AllocatedStorage = aws.Long(int64(d.Get("allocated_storage").(int)))
|
||||
}
|
||||
if d.HasChange("backup_retention_period") {
|
||||
d.SetPartial("backup_retention_period")
|
||||
req.BackupRetentionPeriod = aws.Integer(d.Get("backup_retention_period").(int))
|
||||
req.BackupRetentionPeriod = aws.Long(int64(d.Get("backup_retention_period").(int)))
|
||||
}
|
||||
if d.HasChange("instance_class") {
|
||||
d.SetPartial("instance_class")
|
||||
|
@ -465,7 +465,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
if d.HasChange("iops") {
|
||||
d.SetPartial("iops")
|
||||
req.IOPS = aws.Integer(d.Get("iops").(int))
|
||||
req.IOPS = aws.Long(int64(d.Get("iops").(int)))
|
||||
}
|
||||
if d.HasChange("backup_window") {
|
||||
d.SetPartial("backup_window")
|
||||
|
@ -490,9 +490,9 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
if d.HasChange("vpc_security_group_ids") {
|
||||
if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 {
|
||||
var s []string
|
||||
var s []*string
|
||||
for _, v := range attr.List() {
|
||||
s = append(s, v.(string))
|
||||
s = append(s, aws.String(v.(string)))
|
||||
}
|
||||
req.VPCSecurityGroupIDs = s
|
||||
}
|
||||
|
@ -500,9 +500,9 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
if d.HasChange("vpc_security_group_ids") {
|
||||
if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 {
|
||||
var s []string
|
||||
var s []*string
|
||||
for _, v := range attr.List() {
|
||||
s = append(s, v.(string))
|
||||
s = append(s, aws.String(v.(string)))
|
||||
}
|
||||
req.DBSecurityGroups = s
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ func resourceAwsBbInstanceRetrieve(
|
|||
d *schema.ResourceData, meta interface{}) (*rds.DBInstance, error) {
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
|
||||
opts := rds.DescribeDBInstancesMessage{
|
||||
opts := rds.DescribeDBInstancesInput{
|
||||
DBInstanceIdentifier: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
|
@ -552,9 +552,7 @@ func resourceAwsBbInstanceRetrieve(
|
|||
}
|
||||
}
|
||||
|
||||
v := resp.DBInstances[0]
|
||||
|
||||
return &v, nil
|
||||
return resp.DBInstances[0], nil
|
||||
}
|
||||
|
||||
func resourceAwsDbInstanceStateRefreshFunc(
|
||||
|
@ -578,8 +576,8 @@ func resourceAwsDbInstanceStateRefreshFunc(
|
|||
func buildRDSARN(d *schema.ResourceData, meta interface{}) (string, error) {
|
||||
iamconn := meta.(*AWSClient).iamconn
|
||||
region := meta.(*AWSClient).region
|
||||
// An zero value GetUserRequest{} defers to the currently logged in user
|
||||
resp, err := iamconn.GetUser(&iam.GetUserRequest{})
|
||||
// An zero value GetUserInput{} defers to the currently logged in user
|
||||
resp, err := iamconn.GetUser(&iam.GetUserInput{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func TestAccAWSDBInstance(t *testing.T) {
|
||||
|
@ -56,7 +56,7 @@ func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error {
|
|||
|
||||
// Try to find the Group
|
||||
resp, err := conn.DescribeDBInstances(
|
||||
&rds.DescribeDBInstancesMessage{
|
||||
&rds.DescribeDBInstancesInput{
|
||||
DBInstanceIdentifier: aws.String(rs.Primary.ID),
|
||||
})
|
||||
|
||||
|
@ -112,7 +112,7 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
||||
|
||||
opts := rds.DescribeDBInstancesMessage{
|
||||
opts := rds.DescribeDBInstancesInput{
|
||||
DBInstanceIdentifier: aws.String(rs.Primary.ID),
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
|
|||
return fmt.Errorf("DB Instance not found")
|
||||
}
|
||||
|
||||
*v = resp.DBInstances[0]
|
||||
*v = *resp.DBInstances[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func resourceAwsDbParameterGroup() *schema.Resource {
|
||||
|
@ -75,7 +75,7 @@ func resourceAwsDbParameterGroup() *schema.Resource {
|
|||
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
rdsconn := meta.(*AWSClient).rdsconn
|
||||
|
||||
createOpts := rds.CreateDBParameterGroupMessage{
|
||||
createOpts := rds.CreateDBParameterGroupInput{
|
||||
DBParameterGroupName: aws.String(d.Get("name").(string)),
|
||||
DBParameterGroupFamily: aws.String(d.Get("family").(string)),
|
||||
Description: aws.String(d.Get("description").(string)),
|
||||
|
@ -102,7 +102,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error {
|
||||
rdsconn := meta.(*AWSClient).rdsconn
|
||||
|
||||
describeOpts := rds.DescribeDBParameterGroupsMessage{
|
||||
describeOpts := rds.DescribeDBParameterGroupsInput{
|
||||
DBParameterGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
|
|||
d.Set("description", describeResp.DBParameterGroups[0].Description)
|
||||
|
||||
// Only include user customized parameters as there's hundreds of system/default ones
|
||||
describeParametersOpts := rds.DescribeDBParametersMessage{
|
||||
describeParametersOpts := rds.DescribeDBParametersInput{
|
||||
DBParameterGroupName: aws.String(d.Id()),
|
||||
Source: aws.String("user"),
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
if len(parameters) > 0 {
|
||||
modifyOpts := rds.ModifyDBParameterGroupMessage{
|
||||
modifyOpts := rds.ModifyDBParameterGroupInput{
|
||||
DBParameterGroupName: aws.String(d.Get("name").(string)),
|
||||
Parameters: parameters,
|
||||
}
|
||||
|
@ -198,11 +198,11 @@ func resourceAwsDbParameterGroupDeleteRefreshFunc(
|
|||
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
deleteOpts := rds.DeleteDBParameterGroupMessage{
|
||||
deleteOpts := rds.DeleteDBParameterGroupInput{
|
||||
DBParameterGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
if err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
|
||||
if _, err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
|
||||
rdserr, ok := err.(aws.APIError)
|
||||
if !ok {
|
||||
return d, "error", err
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -115,7 +115,7 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
|
|||
|
||||
// Try to find the Group
|
||||
resp, err := conn.DescribeDBParameterGroups(
|
||||
&rds.DescribeDBParameterGroupsMessage{
|
||||
&rds.DescribeDBParameterGroupsInput{
|
||||
DBParameterGroupName: aws.String(rs.Primary.ID),
|
||||
})
|
||||
|
||||
|
@ -171,7 +171,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
||||
|
||||
opts := rds.DescribeDBParameterGroupsMessage{
|
||||
opts := rds.DescribeDBParameterGroupsInput{
|
||||
DBParameterGroupName: aws.String(rs.Primary.ID),
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
|
|||
return fmt.Errorf("DB Parameter Group not found")
|
||||
}
|
||||
|
||||
*v = resp.DBParameterGroups[0]
|
||||
*v = *resp.DBParameterGroups[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/multierror"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
|
@ -75,7 +75,7 @@ func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{})
|
|||
var err error
|
||||
var errs []error
|
||||
|
||||
opts := rds.CreateDBSecurityGroupMessage{
|
||||
opts := rds.CreateDBSecurityGroupInput{
|
||||
DBSecurityGroupName: aws.String(d.Get("name").(string)),
|
||||
DBSecurityGroupDescription: aws.String(d.Get("description").(string)),
|
||||
}
|
||||
|
@ -164,10 +164,10 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
|
|||
|
||||
log.Printf("[DEBUG] DB Security Group destroy: %v", d.Id())
|
||||
|
||||
opts := rds.DeleteDBSecurityGroupMessage{DBSecurityGroupName: aws.String(d.Id())}
|
||||
opts := rds.DeleteDBSecurityGroupInput{DBSecurityGroupName: aws.String(d.Id())}
|
||||
|
||||
log.Printf("[DEBUG] DB Security Group destroy configuration: %v", opts)
|
||||
err := conn.DeleteDBSecurityGroup(&opts)
|
||||
_, err := conn.DeleteDBSecurityGroup(&opts)
|
||||
|
||||
if err != nil {
|
||||
newerr, ok := err.(aws.APIError)
|
||||
|
@ -183,7 +183,7 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
|
|||
func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}) (*rds.DBSecurityGroup, error) {
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
|
||||
opts := rds.DescribeDBSecurityGroupsMessage{
|
||||
opts := rds.DescribeDBSecurityGroupsInput{
|
||||
DBSecurityGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
|
@ -200,16 +200,14 @@ func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}
|
|||
return nil, fmt.Errorf("Unable to find DB Security Group: %#v", resp.DBSecurityGroups)
|
||||
}
|
||||
|
||||
v := resp.DBSecurityGroups[0]
|
||||
|
||||
return &v, nil
|
||||
return resp.DBSecurityGroups[0], nil
|
||||
}
|
||||
|
||||
// Authorizes the ingress rule on the db security group
|
||||
func resourceAwsDbSecurityGroupAuthorizeRule(ingress interface{}, dbSecurityGroupName string, conn *rds.RDS) error {
|
||||
ing := ingress.(map[string]interface{})
|
||||
|
||||
opts := rds.AuthorizeDBSecurityGroupIngressMessage{
|
||||
opts := rds.AuthorizeDBSecurityGroupIngressInput{
|
||||
DBSecurityGroupName: aws.String(dbSecurityGroupName),
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -47,7 +47,7 @@ func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error {
|
|||
|
||||
// Try to find the Group
|
||||
resp, err := conn.DescribeDBSecurityGroups(
|
||||
&rds.DescribeDBSecurityGroupsMessage{
|
||||
&rds.DescribeDBSecurityGroupsInput{
|
||||
DBSecurityGroupName: aws.String(rs.Primary.ID),
|
||||
})
|
||||
|
||||
|
@ -115,7 +115,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
||||
|
||||
opts := rds.DescribeDBSecurityGroupsMessage{
|
||||
opts := rds.DescribeDBSecurityGroupsInput{
|
||||
DBSecurityGroupName: aws.String(rs.Primary.ID),
|
||||
}
|
||||
|
||||
|
@ -130,13 +130,17 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
|
|||
return fmt.Errorf("DB Security Group not found")
|
||||
}
|
||||
|
||||
*v = resp.DBSecurityGroups[0]
|
||||
*v = *resp.DBSecurityGroups[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccAWSDBSecurityGroupConfig = `
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
resource "aws_db_security_group" "bar" {
|
||||
name = "secgroup-terraform"
|
||||
description = "just cuz"
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -49,12 +49,12 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
|
|||
rdsconn := meta.(*AWSClient).rdsconn
|
||||
|
||||
subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
|
||||
subnetIds := make([]string, subnetIdsSet.Len())
|
||||
subnetIds := make([]*string, subnetIdsSet.Len())
|
||||
for i, subnetId := range subnetIdsSet.List() {
|
||||
subnetIds[i] = subnetId.(string)
|
||||
subnetIds[i] = aws.String(subnetId.(string))
|
||||
}
|
||||
|
||||
createOpts := rds.CreateDBSubnetGroupMessage{
|
||||
createOpts := rds.CreateDBSubnetGroupInput{
|
||||
DBSubnetGroupName: aws.String(d.Get("name").(string)),
|
||||
DBSubnetGroupDescription: aws.String(d.Get("description").(string)),
|
||||
SubnetIDs: subnetIds,
|
||||
|
@ -74,7 +74,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
|
|||
func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error {
|
||||
rdsconn := meta.(*AWSClient).rdsconn
|
||||
|
||||
describeOpts := rds.DescribeDBSubnetGroupsMessage{
|
||||
describeOpts := rds.DescribeDBSubnetGroupsInput{
|
||||
DBSubnetGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
|
|||
return fmt.Errorf("Unable to find DB Subnet Group: %#v", describeResp.DBSubnetGroups)
|
||||
}
|
||||
|
||||
var subnetGroup rds.DBSubnetGroup
|
||||
var subnetGroup *rds.DBSubnetGroup
|
||||
for _, s := range describeResp.DBSubnetGroups {
|
||||
// AWS is down casing the name provided, so we compare lower case versions
|
||||
// of the names. We lower case both our name and their name in the check,
|
||||
|
@ -137,11 +137,11 @@ func resourceAwsDbSubnetGroupDeleteRefreshFunc(
|
|||
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
deleteOpts := rds.DeleteDBSubnetGroupMessage{
|
||||
deleteOpts := rds.DeleteDBSubnetGroupInput{
|
||||
DBSubnetGroupName: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
if err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
|
||||
if _, err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
|
||||
rdserr, ok := err.(aws.APIError)
|
||||
if !ok {
|
||||
return d, "error", err
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func TestAccAWSDBSubnetGroup(t *testing.T) {
|
||||
|
@ -45,7 +45,7 @@ func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error {
|
|||
|
||||
// Try to find the resource
|
||||
resp, err := conn.DescribeDBSubnetGroups(
|
||||
&rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)})
|
||||
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
|
||||
if err == nil {
|
||||
if len(resp.DBSubnetGroups) > 0 {
|
||||
return fmt.Errorf("still exist.")
|
||||
|
@ -80,7 +80,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
||||
resp, err := conn.DescribeDBSubnetGroups(
|
||||
&rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)})
|
||||
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
|
|||
return fmt.Errorf("DbSubnetGroup not found")
|
||||
}
|
||||
|
||||
*v = resp.DBSubnetGroups[0]
|
||||
*v = *resp.DBSubnetGroups[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ func resourceAwsEip() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2SDKconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// By default, we're not in a VPC
|
||||
domainOpt := ""
|
||||
|
@ -97,7 +97,7 @@ func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2SDKconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
domain := resourceAwsEipDomain(d)
|
||||
id := d.Id()
|
||||
|
@ -148,7 +148,7 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2SDKconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
domain := resourceAwsEipDomain(d)
|
||||
|
||||
|
@ -181,7 +181,7 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2SDKconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if err := resourceAwsEipRead(d, meta); err != nil {
|
||||
return err
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestAccAWSEIP_instance(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckAWSEIPDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
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")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
if strings.Contains(rs.Primary.ID, "eipalloc") {
|
||||
req := &ec2.DescribeAddressesInput{
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -163,7 +163,7 @@ func resourceAwsElb() *schema.Resource {
|
|||
func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
elbconn := meta.(*AWSClient).elbconn
|
||||
|
||||
// Expand the "listener" set to aws-sdk-go compat []elb.Listener
|
||||
// Expand the "listener" set to aws-sdk-go compat []*elb.Listener
|
||||
listeners, err := expandListeners(d.Get("listener").(*schema.Set).List())
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -171,7 +171,7 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
tags := tagsFromMapELB(d.Get("tags").(map[string]interface{}))
|
||||
// Provision the elb
|
||||
elbOpts := &elb.CreateAccessPointInput{
|
||||
elbOpts := &elb.CreateLoadBalancerInput{
|
||||
LoadBalancerName: aws.String(d.Get("name").(string)),
|
||||
Listeners: listeners,
|
||||
Tags: tags,
|
||||
|
@ -221,11 +221,11 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
configureHealthCheckOpts := elb.ConfigureHealthCheckInput{
|
||||
LoadBalancerName: aws.String(d.Id()),
|
||||
HealthCheck: &elb.HealthCheck{
|
||||
HealthyThreshold: aws.Integer(check["healthy_threshold"].(int)),
|
||||
UnhealthyThreshold: aws.Integer(check["unhealthy_threshold"].(int)),
|
||||
Interval: aws.Integer(check["interval"].(int)),
|
||||
HealthyThreshold: aws.Long(int64(check["healthy_threshold"].(int))),
|
||||
UnhealthyThreshold: aws.Long(int64(check["unhealthy_threshold"].(int))),
|
||||
Interval: aws.Long(int64(check["interval"].(int))),
|
||||
Target: aws.String(check["target"].(string)),
|
||||
Timeout: aws.Integer(check["timeout"].(int)),
|
||||
Timeout: aws.Long(int64(check["timeout"].(int))),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -243,8 +243,8 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
|
|||
elbconn := meta.(*AWSClient).elbconn
|
||||
|
||||
// Retrieve the ELB properties for updating the state
|
||||
describeElbOpts := &elb.DescribeAccessPointsInput{
|
||||
LoadBalancerNames: []string{d.Id()},
|
||||
describeElbOpts := &elb.DescribeLoadBalancersInput{
|
||||
LoadBalancerNames: []*string{aws.String(d.Id())},
|
||||
}
|
||||
|
||||
describeResp, err := elbconn.DescribeLoadBalancers(describeElbOpts)
|
||||
|
@ -273,10 +273,10 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("subnets", lb.Subnets)
|
||||
|
||||
resp, err := elbconn.DescribeTags(&elb.DescribeTagsInput{
|
||||
LoadBalancerNames: []string{*lb.LoadBalancerName},
|
||||
LoadBalancerNames: []*string{lb.LoadBalancerName},
|
||||
})
|
||||
|
||||
var et []elb.Tag
|
||||
var et []*elb.Tag
|
||||
if len(resp.TagDescriptions) > 0 {
|
||||
et = resp.TagDescriptions[0].Tags
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
add := expandInstanceString(ns.Difference(os).List())
|
||||
|
||||
if len(add) > 0 {
|
||||
registerInstancesOpts := elb.RegisterEndPointsInput{
|
||||
registerInstancesOpts := elb.RegisterInstancesWithLoadBalancerInput{
|
||||
LoadBalancerName: aws.String(d.Id()),
|
||||
Instances: add,
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
}
|
||||
if len(remove) > 0 {
|
||||
deRegisterInstancesOpts := elb.DeregisterEndPointsInput{
|
||||
deRegisterInstancesOpts := elb.DeregisterInstancesFromLoadBalancerInput{
|
||||
LoadBalancerName: aws.String(d.Id()),
|
||||
Instances: remove,
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
LoadBalancerName: aws.String(d.Get("name").(string)),
|
||||
LoadBalancerAttributes: &elb.LoadBalancerAttributes{
|
||||
CrossZoneLoadBalancing: &elb.CrossZoneLoadBalancing{
|
||||
aws.Boolean(d.Get("cross_zone_load_balancing").(bool)),
|
||||
Enabled: aws.Boolean(d.Get("cross_zone_load_balancing").(bool)),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -356,11 +356,11 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
configureHealthCheckOpts := elb.ConfigureHealthCheckInput{
|
||||
LoadBalancerName: aws.String(d.Id()),
|
||||
HealthCheck: &elb.HealthCheck{
|
||||
HealthyThreshold: aws.Integer(check["healthy_threshold"].(int)),
|
||||
UnhealthyThreshold: aws.Integer(check["unhealthy_threshold"].(int)),
|
||||
Interval: aws.Integer(check["interval"].(int)),
|
||||
HealthyThreshold: aws.Long(int64(check["healthy_threshold"].(int))),
|
||||
UnhealthyThreshold: aws.Long(int64(check["unhealthy_threshold"].(int))),
|
||||
Interval: aws.Long(int64(check["interval"].(int))),
|
||||
Target: aws.String(check["target"].(string)),
|
||||
Timeout: aws.Integer(check["timeout"].(int)),
|
||||
Timeout: aws.Long(int64(check["timeout"].(int))),
|
||||
},
|
||||
}
|
||||
_, err := elbconn.ConfigureHealthCheck(&configureHealthCheckOpts)
|
||||
|
@ -387,7 +387,7 @@ func resourceAwsElbDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[INFO] Deleting ELB: %s", d.Id())
|
||||
|
||||
// Destroy the load balancer
|
||||
deleteElbOpts := elb.DeleteAccessPointInput{
|
||||
deleteElbOpts := elb.DeleteLoadBalancerInput{
|
||||
LoadBalancerName: aws.String(d.Id()),
|
||||
}
|
||||
if _, err := elbconn.DeleteLoadBalancer(&deleteElbOpts); err != nil {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -95,14 +95,14 @@ func testAccLoadTags(conf *elb.LoadBalancerDescription, td *elb.TagDescription)
|
|||
conn := testAccProvider.Meta().(*AWSClient).elbconn
|
||||
|
||||
describe, err := conn.DescribeTags(&elb.DescribeTagsInput{
|
||||
LoadBalancerNames: []string{*conf.LoadBalancerName},
|
||||
LoadBalancerNames: []*string{conf.LoadBalancerName},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(describe.TagDescriptions) > 0 {
|
||||
*td = describe.TagDescriptions[0]
|
||||
*td = *describe.TagDescriptions[0]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -205,8 +205,8 @@ func testAccCheckAWSELBDestroy(s *terraform.State) error {
|
|||
continue
|
||||
}
|
||||
|
||||
describe, err := conn.DescribeLoadBalancers(&elb.DescribeAccessPointsInput{
|
||||
LoadBalancerNames: []string{rs.Primary.ID},
|
||||
describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{
|
||||
LoadBalancerNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
@ -233,8 +233,12 @@ func testAccCheckAWSELBDestroy(s *terraform.State) error {
|
|||
func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"}
|
||||
sort.StringSlice(conf.AvailabilityZones).Sort()
|
||||
if !reflect.DeepEqual(conf.AvailabilityZones, zones) {
|
||||
azs := make([]string, 0, len(conf.AvailabilityZones))
|
||||
for _, x := range conf.AvailabilityZones {
|
||||
azs = append(azs, *x)
|
||||
}
|
||||
sort.StringSlice(azs).Sort()
|
||||
if !reflect.DeepEqual(azs, zones) {
|
||||
return fmt.Errorf("bad availability_zones")
|
||||
}
|
||||
|
||||
|
@ -243,9 +247,9 @@ func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.Te
|
|||
}
|
||||
|
||||
l := elb.Listener{
|
||||
InstancePort: aws.Integer(8000),
|
||||
InstancePort: aws.Long(int64(8000)),
|
||||
InstanceProtocol: aws.String("HTTP"),
|
||||
LoadBalancerPort: aws.Integer(80),
|
||||
LoadBalancerPort: aws.Long(int64(80)),
|
||||
Protocol: aws.String("HTTP"),
|
||||
}
|
||||
|
||||
|
@ -267,8 +271,12 @@ func testAccCheckAWSELBAttributes(conf *elb.LoadBalancerDescription) resource.Te
|
|||
func testAccCheckAWSELBAttributesHealthCheck(conf *elb.LoadBalancerDescription) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
zones := []string{"us-west-2a", "us-west-2b", "us-west-2c"}
|
||||
sort.StringSlice(conf.AvailabilityZones).Sort()
|
||||
if !reflect.DeepEqual(conf.AvailabilityZones, zones) {
|
||||
azs := make([]string, 0, len(conf.AvailabilityZones))
|
||||
for _, x := range conf.AvailabilityZones {
|
||||
azs = append(azs, *x)
|
||||
}
|
||||
sort.StringSlice(azs).Sort()
|
||||
if !reflect.DeepEqual(azs, zones) {
|
||||
return fmt.Errorf("bad availability_zones")
|
||||
}
|
||||
|
||||
|
@ -276,15 +284,15 @@ func testAccCheckAWSELBAttributesHealthCheck(conf *elb.LoadBalancerDescription)
|
|||
return fmt.Errorf("bad name")
|
||||
}
|
||||
|
||||
check := elb.HealthCheck{
|
||||
Timeout: aws.Integer(30),
|
||||
UnhealthyThreshold: aws.Integer(5),
|
||||
HealthyThreshold: aws.Integer(5),
|
||||
Interval: aws.Integer(60),
|
||||
check := &elb.HealthCheck{
|
||||
Timeout: aws.Long(int64(30)),
|
||||
UnhealthyThreshold: aws.Long(int64(5)),
|
||||
HealthyThreshold: aws.Long(int64(5)),
|
||||
Interval: aws.Long(int64(60)),
|
||||
Target: aws.String("HTTP:8000/"),
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(conf.HealthCheck, &check) {
|
||||
if !reflect.DeepEqual(conf.HealthCheck, check) {
|
||||
return fmt.Errorf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
conf.HealthCheck,
|
||||
|
@ -312,8 +320,8 @@ func testAccCheckAWSELBExists(n string, res *elb.LoadBalancerDescription) resour
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).elbconn
|
||||
|
||||
describe, err := conn.DescribeLoadBalancers(&elb.DescribeAccessPointsInput{
|
||||
LoadBalancerNames: []string{rs.Primary.ID},
|
||||
describe, err := conn.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{
|
||||
LoadBalancerNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
@ -325,7 +333,7 @@ func testAccCheckAWSELBExists(n string, res *elb.LoadBalancerDescription) resour
|
|||
return fmt.Errorf("ELB not found")
|
||||
}
|
||||
|
||||
*res = describe.LoadBalancerDescriptions[0]
|
||||
*res = *describe.LoadBalancerDescriptions[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -105,6 +105,16 @@ func resourceAwsInstance() *schema.Resource {
|
|||
},
|
||||
},
|
||||
|
||||
"vpc_security_group_ids": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
},
|
||||
|
||||
"public_dns": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -289,7 +299,7 @@ func resourceAwsInstance() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Figure out user data
|
||||
userData := ""
|
||||
|
@ -319,12 +329,12 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
// Build the creation struct
|
||||
runOpts := &ec2.RunInstancesRequest{
|
||||
runOpts := &ec2.RunInstancesInput{
|
||||
ImageID: aws.String(d.Get("ami").(string)),
|
||||
Placement: placement,
|
||||
InstanceType: aws.String(d.Get("instance_type").(string)),
|
||||
MaxCount: aws.Integer(1),
|
||||
MinCount: aws.Integer(1),
|
||||
MaxCount: aws.Long(int64(1)),
|
||||
MinCount: aws.Long(int64(1)),
|
||||
UserData: aws.String(userData),
|
||||
EBSOptimized: aws.Boolean(d.Get("ebs_optimized").(bool)),
|
||||
IAMInstanceProfile: iam,
|
||||
|
@ -335,14 +345,17 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
associatePublicIPAddress = v.(bool)
|
||||
}
|
||||
|
||||
var groups []string
|
||||
var groups []*string
|
||||
if v := d.Get("security_groups"); v != nil {
|
||||
// Security group names.
|
||||
// For a nondefault VPC, you must use security group IDs instead.
|
||||
// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html
|
||||
if hasSubnet {
|
||||
log.Printf("[WARN] Deprecated. Attempting to use 'security_groups' within a VPC instance. Use 'vpc_security_group_ids' instead.")
|
||||
}
|
||||
for _, v := range v.(*schema.Set).List() {
|
||||
str := v.(string)
|
||||
groups = append(groups, str)
|
||||
groups = append(groups, aws.String(str))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,9 +367,9 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
// You also need to attach Security Groups to the NetworkInterface instead of the instance,
|
||||
// to avoid: Network interfaces and an instance-level security groups may not be specified on
|
||||
// the same request
|
||||
ni := ec2.InstanceNetworkInterfaceSpecification{
|
||||
ni := &ec2.InstanceNetworkInterfaceSpecification{
|
||||
AssociatePublicIPAddress: aws.Boolean(associatePublicIPAddress),
|
||||
DeviceIndex: aws.Integer(0),
|
||||
DeviceIndex: aws.Long(int64(0)),
|
||||
SubnetID: aws.String(subnetID),
|
||||
}
|
||||
|
||||
|
@ -364,11 +377,13 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
ni.PrivateIPAddress = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
ni.Groups = groups
|
||||
if v := d.Get("vpc_security_group_ids"); v != nil {
|
||||
for _, v := range v.(*schema.Set).List() {
|
||||
ni.Groups = append(ni.Groups, aws.String(v.(string)))
|
||||
}
|
||||
}
|
||||
|
||||
runOpts.NetworkInterfaces = []ec2.InstanceNetworkInterfaceSpecification{ni}
|
||||
runOpts.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{ni}
|
||||
} else {
|
||||
if subnetID != "" {
|
||||
runOpts.SubnetID = aws.String(subnetID)
|
||||
|
@ -383,13 +398,19 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
} else {
|
||||
runOpts.SecurityGroups = groups
|
||||
}
|
||||
|
||||
if v := d.Get("vpc_security_group_ids"); v != nil {
|
||||
for _, v := range v.(*schema.Set).List() {
|
||||
runOpts.SecurityGroupIDs = append(runOpts.SecurityGroupIDs, aws.String(v.(string)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("key_name"); ok {
|
||||
runOpts.KeyName = aws.String(v.(string))
|
||||
}
|
||||
|
||||
blockDevices := make([]ec2.BlockDeviceMapping, 0)
|
||||
blockDevices := make([]*ec2.BlockDeviceMapping, 0)
|
||||
|
||||
if v, ok := d.GetOk("ebs_block_device"); ok {
|
||||
vL := v.(*schema.Set).List()
|
||||
|
@ -404,7 +425,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
if v, ok := bd["volume_size"].(int); ok && v != 0 {
|
||||
ebs.VolumeSize = aws.Integer(v)
|
||||
ebs.VolumeSize = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if v, ok := bd["volume_type"].(string); ok && v != "" {
|
||||
|
@ -412,10 +433,10 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
if v, ok := bd["iops"].(int); ok && v > 0 {
|
||||
ebs.IOPS = aws.Integer(v)
|
||||
ebs.IOPS = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
blockDevices = append(blockDevices, ec2.BlockDeviceMapping{
|
||||
blockDevices = append(blockDevices, &ec2.BlockDeviceMapping{
|
||||
DeviceName: aws.String(bd["device_name"].(string)),
|
||||
EBS: ebs,
|
||||
})
|
||||
|
@ -426,7 +447,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
vL := v.(*schema.Set).List()
|
||||
for _, v := range vL {
|
||||
bd := v.(map[string]interface{})
|
||||
blockDevices = append(blockDevices, ec2.BlockDeviceMapping{
|
||||
blockDevices = append(blockDevices, &ec2.BlockDeviceMapping{
|
||||
DeviceName: aws.String(bd["device_name"].(string)),
|
||||
VirtualName: aws.String(bd["virtual_name"].(string)),
|
||||
})
|
||||
|
@ -445,7 +466,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
if v, ok := bd["volume_size"].(int); ok && v != 0 {
|
||||
ebs.VolumeSize = aws.Integer(v)
|
||||
ebs.VolumeSize = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if v, ok := bd["volume_type"].(string); ok && v != "" {
|
||||
|
@ -453,11 +474,11 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
if v, ok := bd["iops"].(int); ok && v > 0 {
|
||||
ebs.IOPS = aws.Integer(v)
|
||||
ebs.IOPS = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if dn, err := fetchRootDeviceName(d.Get("ami").(string), ec2conn); err == nil {
|
||||
blockDevices = append(blockDevices, ec2.BlockDeviceMapping{
|
||||
if dn, err := fetchRootDeviceName(d.Get("ami").(string), conn); err == nil {
|
||||
blockDevices = append(blockDevices, &ec2.BlockDeviceMapping{
|
||||
DeviceName: dn,
|
||||
EBS: ebs,
|
||||
})
|
||||
|
@ -473,12 +494,12 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
// Create the instance
|
||||
log.Printf("[DEBUG] Run configuration: %#v", runOpts)
|
||||
runResp, err := ec2conn.RunInstances(runOpts)
|
||||
runResp, err := conn.RunInstances(runOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error launching source instance: %s", err)
|
||||
}
|
||||
|
||||
instance := &runResp.Instances[0]
|
||||
instance := runResp.Instances[0]
|
||||
log.Printf("[INFO] Instance ID: %s", *instance.InstanceID)
|
||||
|
||||
// Store the resulting ID so we can look this up later
|
||||
|
@ -493,7 +514,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending"},
|
||||
Target: "running",
|
||||
Refresh: InstanceStateRefreshFunc(ec2conn, *instance.InstanceID),
|
||||
Refresh: InstanceStateRefreshFunc(conn, *instance.InstanceID),
|
||||
Timeout: 10 * time.Minute,
|
||||
Delay: 10 * time.Second,
|
||||
MinTimeout: 3 * time.Second,
|
||||
|
@ -526,10 +547,10 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
resp, err := ec2conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||
InstanceIDs: []string{d.Id()},
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
InstanceIDs: []*string{aws.String(d.Id())},
|
||||
})
|
||||
if err != nil {
|
||||
// If the instance was not found, return nil so that we can show
|
||||
|
@ -549,7 +570,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
instance := &resp.Reservations[0].Instances[0]
|
||||
instance := resp.Reservations[0].Instances[0]
|
||||
|
||||
// If the instance is terminated, then it is gone
|
||||
if *instance.State.Name == "terminated" {
|
||||
|
@ -575,7 +596,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("subnet_id", instance.SubnetID)
|
||||
}
|
||||
d.Set("ebs_optimized", instance.EBSOptimized)
|
||||
d.Set("tags", tagsToMap(instance.Tags))
|
||||
d.Set("tags", tagsToMapSDK(instance.Tags))
|
||||
|
||||
// Determine whether we're referring to security groups with
|
||||
// IDs or names. We use a heuristic to figure this out. By default,
|
||||
|
@ -596,17 +617,26 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
// Build up the security groups
|
||||
sgs := make([]string, len(instance.SecurityGroups))
|
||||
for i, sg := range instance.SecurityGroups {
|
||||
if useID {
|
||||
sgs[i] = *sg.GroupID
|
||||
} else {
|
||||
sgs[i] = *sg.GroupName
|
||||
sgs := make([]string, 0, len(instance.SecurityGroups))
|
||||
if useID {
|
||||
for _, sg := range instance.SecurityGroups {
|
||||
sgs = append(sgs, *sg.GroupID)
|
||||
}
|
||||
log.Printf("[DEBUG] Setting Security Group IDs: %#v", sgs)
|
||||
if err := d.Set("vpc_security_group_ids", sgs); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
for _, sg := range instance.SecurityGroups {
|
||||
sgs = append(sgs, *sg.GroupName)
|
||||
}
|
||||
log.Printf("[DEBUG] Setting Security Group Names: %#v", sgs)
|
||||
if err := d.Set("security_groups", sgs); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
d.Set("security_groups", sgs)
|
||||
|
||||
if err := readBlockDevices(d, instance, ec2conn); err != nil {
|
||||
if err := readBlockDevices(d, instance, conn); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -614,12 +644,14 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
d.Partial(true)
|
||||
|
||||
// SourceDestCheck can only be set on VPC instances
|
||||
if d.Get("subnet_id").(string) != "" {
|
||||
log.Printf("[INFO] Modifying instance %s", d.Id())
|
||||
err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeRequest{
|
||||
_, err := conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
|
||||
InstanceID: aws.String(d.Id()),
|
||||
SourceDestCheck: &ec2.AttributeBooleanValue{
|
||||
Value: aws.Boolean(d.Get("source_dest_check").(bool)),
|
||||
|
@ -633,23 +665,24 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
// TODO(mitchellh): wait for the attributes we modified to
|
||||
// persist the change...
|
||||
|
||||
if err := setTags(ec2conn, d); err != nil {
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
}
|
||||
d.Partial(false)
|
||||
|
||||
return nil
|
||||
return resourceAwsInstanceRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsInstanceDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[INFO] Terminating instance: %s", d.Id())
|
||||
req := &ec2.TerminateInstancesRequest{
|
||||
InstanceIDs: []string{d.Id()},
|
||||
req := &ec2.TerminateInstancesInput{
|
||||
InstanceIDs: []*string{aws.String(d.Id())},
|
||||
}
|
||||
if _, err := ec2conn.TerminateInstances(req); err != nil {
|
||||
if _, err := conn.TerminateInstances(req); err != nil {
|
||||
return fmt.Errorf("Error terminating instance: %s", err)
|
||||
}
|
||||
|
||||
|
@ -660,7 +693,7 @@ func resourceAwsInstanceDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending", "running", "shutting-down", "stopped", "stopping"},
|
||||
Target: "terminated",
|
||||
Refresh: InstanceStateRefreshFunc(ec2conn, d.Id()),
|
||||
Refresh: InstanceStateRefreshFunc(conn, d.Id()),
|
||||
Timeout: 10 * time.Minute,
|
||||
Delay: 10 * time.Second,
|
||||
MinTimeout: 3 * time.Second,
|
||||
|
@ -681,8 +714,8 @@ func resourceAwsInstanceDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
// an EC2 instance.
|
||||
func InstanceStateRefreshFunc(conn *ec2.EC2, instanceID string) resource.StateRefreshFunc {
|
||||
return func() (interface{}, string, error) {
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||
InstanceIDs: []string{instanceID},
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
InstanceIDs: []*string{aws.String(instanceID)},
|
||||
})
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidInstanceID.NotFound" {
|
||||
|
@ -700,13 +733,13 @@ func InstanceStateRefreshFunc(conn *ec2.EC2, instanceID string) resource.StateRe
|
|||
return nil, "", nil
|
||||
}
|
||||
|
||||
i := &resp.Reservations[0].Instances[0]
|
||||
i := resp.Reservations[0].Instances[0]
|
||||
return i, *i.State.Name, nil
|
||||
}
|
||||
}
|
||||
|
||||
func readBlockDevices(d *schema.ResourceData, instance *ec2.Instance, ec2conn *ec2.EC2) error {
|
||||
ibds, err := readBlockDevicesFromInstance(instance, ec2conn)
|
||||
func readBlockDevices(d *schema.ResourceData, instance *ec2.Instance, conn *ec2.EC2) error {
|
||||
ibds, err := readBlockDevicesFromInstance(instance, conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -723,12 +756,12 @@ func readBlockDevices(d *schema.ResourceData, instance *ec2.Instance, ec2conn *e
|
|||
return nil
|
||||
}
|
||||
|
||||
func readBlockDevicesFromInstance(instance *ec2.Instance, ec2conn *ec2.EC2) (map[string]interface{}, error) {
|
||||
func readBlockDevicesFromInstance(instance *ec2.Instance, conn *ec2.EC2) (map[string]interface{}, error) {
|
||||
blockDevices := make(map[string]interface{})
|
||||
blockDevices["ebs"] = make([]map[string]interface{}, 0)
|
||||
blockDevices["root"] = nil
|
||||
|
||||
instanceBlockDevices := make(map[string]ec2.InstanceBlockDeviceMapping)
|
||||
instanceBlockDevices := make(map[string]*ec2.InstanceBlockDeviceMapping)
|
||||
for _, bd := range instance.BlockDeviceMappings {
|
||||
if bd.EBS != nil {
|
||||
instanceBlockDevices[*(bd.EBS.VolumeID)] = bd
|
||||
|
@ -739,14 +772,14 @@ func readBlockDevicesFromInstance(instance *ec2.Instance, ec2conn *ec2.EC2) (map
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
volIDs := make([]string, 0, len(instanceBlockDevices))
|
||||
volIDs := make([]*string, 0, len(instanceBlockDevices))
|
||||
for volID := range instanceBlockDevices {
|
||||
volIDs = append(volIDs, volID)
|
||||
volIDs = append(volIDs, aws.String(volID))
|
||||
}
|
||||
|
||||
// Need to call DescribeVolumes to get volume_size and volume_type for each
|
||||
// EBS block device
|
||||
volResp, err := ec2conn.DescribeVolumes(&ec2.DescribeVolumesRequest{
|
||||
volResp, err := conn.DescribeVolumes(&ec2.DescribeVolumesInput{
|
||||
VolumeIDs: volIDs,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -790,19 +823,19 @@ func readBlockDevicesFromInstance(instance *ec2.Instance, ec2conn *ec2.EC2) (map
|
|||
return blockDevices, nil
|
||||
}
|
||||
|
||||
func blockDeviceIsRoot(bd ec2.InstanceBlockDeviceMapping, instance *ec2.Instance) bool {
|
||||
func blockDeviceIsRoot(bd *ec2.InstanceBlockDeviceMapping, instance *ec2.Instance) bool {
|
||||
return (bd.DeviceName != nil &&
|
||||
instance.RootDeviceName != nil &&
|
||||
*bd.DeviceName == *instance.RootDeviceName)
|
||||
}
|
||||
|
||||
func fetchRootDeviceName(ami string, conn *ec2.EC2) (aws.StringValue, error) {
|
||||
func fetchRootDeviceName(ami string, conn *ec2.EC2) (*string, error) {
|
||||
if ami == "" {
|
||||
return nil, fmt.Errorf("Cannot fetch root device name for blank AMI ID.")
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Describing AMI %q to get root block device name", ami)
|
||||
req := &ec2.DescribeImagesRequest{ImageIDs: []string{ami}}
|
||||
req := &ec2.DescribeImagesInput{ImageIDs: []*string{aws.String(ami)}}
|
||||
if res, err := conn.DescribeImages(req); err == nil {
|
||||
if len(res.Images) == 1 {
|
||||
return res.Images[0].RootDeviceName, nil
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
@ -43,9 +43,9 @@ func TestAccAWSInstance_normal(t *testing.T) {
|
|||
Check: func(*terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
var err error
|
||||
vol, err = conn.CreateVolume(&ec2.CreateVolumeRequest{
|
||||
vol, err = conn.CreateVolume(&ec2.CreateVolumeInput{
|
||||
AvailabilityZone: aws.String("us-west-2a"),
|
||||
Size: aws.Integer(5),
|
||||
Size: aws.Long(int64(5)),
|
||||
})
|
||||
return err
|
||||
},
|
||||
|
@ -89,7 +89,8 @@ func TestAccAWSInstance_normal(t *testing.T) {
|
|||
Config: testAccInstanceConfig,
|
||||
Check: func(*terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
return conn.DeleteVolume(&ec2.DeleteVolumeRequest{VolumeID: vol.VolumeID})
|
||||
_, err := conn.DeleteVolume(&ec2.DeleteVolumeInput{VolumeID: vol.VolumeID})
|
||||
return err
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -103,7 +104,7 @@ func TestAccAWSInstance_blockDevices(t *testing.T) {
|
|||
return func(*terraform.State) error {
|
||||
|
||||
// Map out the block devices by name, which should be unique.
|
||||
blockDevices := make(map[string]ec2.InstanceBlockDeviceMapping)
|
||||
blockDevices := make(map[string]*ec2.InstanceBlockDeviceMapping)
|
||||
for _, blockDevice := range v.BlockDeviceMappings {
|
||||
blockDevices[*blockDevice.DeviceName] = blockDevice
|
||||
}
|
||||
|
@ -255,6 +256,25 @@ func TestAccAWSInstance_NetworkInstanceSecurityGroups(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs(t *testing.T) {
|
||||
var v ec2.Instance
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccInstanceNetworkInstanceVPCSecurityGroupIDs,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceExists(
|
||||
"aws_instance.foo_instance", &v),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSInstance_tags(t *testing.T) {
|
||||
var v ec2.Instance
|
||||
|
||||
|
@ -267,9 +287,9 @@ func TestAccAWSInstance_tags(t *testing.T) {
|
|||
Config: testAccCheckInstanceConfigTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceExists("aws_instance.foo", &v),
|
||||
testAccCheckTags(&v.Tags, "foo", "bar"),
|
||||
testAccCheckTagsSDK(&v.Tags, "foo", "bar"),
|
||||
// Guard against regression of https://github.com/hashicorp/terraform/issues/914
|
||||
testAccCheckTags(&v.Tags, "#", ""),
|
||||
testAccCheckTagsSDK(&v.Tags, "#", ""),
|
||||
),
|
||||
},
|
||||
|
||||
|
@ -277,8 +297,8 @@ func TestAccAWSInstance_tags(t *testing.T) {
|
|||
Config: testAccCheckInstanceConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceExists("aws_instance.foo", &v),
|
||||
testAccCheckTags(&v.Tags, "foo", ""),
|
||||
testAccCheckTags(&v.Tags, "bar", "baz"),
|
||||
testAccCheckTagsSDK(&v.Tags, "foo", ""),
|
||||
testAccCheckTagsSDK(&v.Tags, "bar", "baz"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -352,8 +372,8 @@ func testAccCheckInstanceDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find the resource
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||
InstanceIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
InstanceIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
if len(resp.Reservations) > 0 {
|
||||
|
@ -388,8 +408,8 @@ func testAccCheckInstanceExists(n string, i *ec2.Instance) resource.TestCheckFun
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesRequest{
|
||||
InstanceIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
InstanceIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -398,7 +418,7 @@ func testAccCheckInstanceExists(n string, i *ec2.Instance) resource.TestCheckFun
|
|||
return fmt.Errorf("Instance not found")
|
||||
}
|
||||
|
||||
*i = resp.Reservations[0].Instances[0]
|
||||
*i = *resp.Reservations[0].Instances[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -645,3 +665,48 @@ resource "aws_eip" "foo_eip" {
|
|||
depends_on = ["aws_internet_gateway.gw"]
|
||||
}
|
||||
`
|
||||
|
||||
const testAccInstanceNetworkInstanceVPCSecurityGroupIDs = `
|
||||
resource "aws_internet_gateway" "gw" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
}
|
||||
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "10.1.0.0/16"
|
||||
tags {
|
||||
Name = "tf-network-test"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_security_group" "tf_test_foo" {
|
||||
name = "tf_test_foo"
|
||||
description = "foo"
|
||||
vpc_id="${aws_vpc.foo.id}"
|
||||
|
||||
ingress {
|
||||
protocol = "icmp"
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "foo" {
|
||||
cidr_block = "10.1.1.0/24"
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
}
|
||||
|
||||
resource "aws_instance" "foo_instance" {
|
||||
ami = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
vpc_security_group_ids = ["${aws_security_group.tf_test_foo.id}"]
|
||||
subnet_id = "${aws_subnet.foo.id}"
|
||||
depends_on = ["aws_internet_gateway.gw"]
|
||||
}
|
||||
|
||||
resource "aws_eip" "foo_eip" {
|
||||
instance = "${aws_instance.foo_instance.id}"
|
||||
vpc = true
|
||||
depends_on = ["aws_internet_gateway.gw"]
|
||||
}
|
||||
`
|
||||
|
|
|
@ -29,7 +29,7 @@ func resourceAwsInternetGateway() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Create the 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 {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
igRaw, _, err := IGStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
|
@ -91,7 +91,7 @@ func resourceAwsInternetGatewayUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
}
|
||||
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
|
@ -103,7 +103,7 @@ func resourceAwsInternetGatewayUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceAwsInternetGatewayDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Detach if it is attached
|
||||
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 {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if d.Get("vpc_id").(string) == "" {
|
||||
log.Printf(
|
||||
|
@ -182,7 +182,7 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceAwsInternetGatewayDetach(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Get the old VPC ID to detach from
|
||||
vpcID, _ := d.GetChange("vpc_id")
|
||||
|
|
|
@ -115,7 +115,7 @@ func TestAccAWSInternetGateway_tags(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckInternetGatewayDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
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")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeInternetGateways(&ec2.DescribeInternetGatewaysInput{
|
||||
InternetGatewayIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
|
|
@ -36,7 +36,7 @@ func resourceAwsKeyPair() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
keyName := d.Get("key_name").(string)
|
||||
publicKey := d.Get("public_key").(string)
|
||||
|
@ -54,7 +54,7 @@ func resourceAwsKeyPairCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
req := &ec2.DescribeKeyPairsInput{
|
||||
KeyNames: []*string{aws.String(d.Id())},
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsKeyPairDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
_, err := conn.DeleteKeyPair(&ec2.DeleteKeyPairInput{
|
||||
KeyName: aws.String(d.Id()),
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestAccAWSKeyPair_normal(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckAWSKeyPairDestroy(s *terraform.State) error {
|
||||
ec2SDKconn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_key_pair" {
|
||||
|
@ -38,7 +38,7 @@ func testAccCheckAWSKeyPairDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find key pair
|
||||
resp, err := ec2SDKconn.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{
|
||||
resp, err := ec2conn.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{
|
||||
KeyNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
|
@ -81,9 +81,9 @@ func testAccCheckAWSKeyPairExists(n string, res *ec2.KeyPairInfo) resource.TestC
|
|||
return fmt.Errorf("No KeyPair name is set")
|
||||
}
|
||||
|
||||
ec2SDKconn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
resp, err := ec2SDKconn.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{
|
||||
resp, err := ec2conn.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{
|
||||
KeyNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -245,7 +245,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
createLaunchConfigurationOpts := autoscaling.CreateLaunchConfigurationType{
|
||||
createLaunchConfigurationOpts := autoscaling.CreateLaunchConfigurationInput{
|
||||
LaunchConfigurationName: aws.String(d.Get("name").(string)),
|
||||
ImageID: aws.String(d.Get("image_id").(string)),
|
||||
InstanceType: aws.String(d.Get("instance_type").(string)),
|
||||
|
@ -282,7 +282,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
)
|
||||
}
|
||||
|
||||
var blockDevices []autoscaling.BlockDeviceMapping
|
||||
var blockDevices []*autoscaling.BlockDeviceMapping
|
||||
|
||||
if v, ok := d.GetOk("ebs_block_device"); ok {
|
||||
vL := v.(*schema.Set).List()
|
||||
|
@ -297,7 +297,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
if v, ok := bd["volume_size"].(int); ok && v != 0 {
|
||||
ebs.VolumeSize = aws.Integer(v)
|
||||
ebs.VolumeSize = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if v, ok := bd["volume_type"].(string); ok && v != "" {
|
||||
|
@ -305,10 +305,10 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
if v, ok := bd["iops"].(int); ok && v > 0 {
|
||||
ebs.IOPS = aws.Integer(v)
|
||||
ebs.IOPS = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
blockDevices = append(blockDevices, autoscaling.BlockDeviceMapping{
|
||||
blockDevices = append(blockDevices, &autoscaling.BlockDeviceMapping{
|
||||
DeviceName: aws.String(bd["device_name"].(string)),
|
||||
EBS: ebs,
|
||||
})
|
||||
|
@ -319,7 +319,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
vL := v.(*schema.Set).List()
|
||||
for _, v := range vL {
|
||||
bd := v.(map[string]interface{})
|
||||
blockDevices = append(blockDevices, autoscaling.BlockDeviceMapping{
|
||||
blockDevices = append(blockDevices, &autoscaling.BlockDeviceMapping{
|
||||
DeviceName: aws.String(bd["device_name"].(string)),
|
||||
VirtualName: aws.String(bd["virtual_name"].(string)),
|
||||
})
|
||||
|
@ -338,7 +338,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
if v, ok := bd["volume_size"].(int); ok && v != 0 {
|
||||
ebs.VolumeSize = aws.Integer(v)
|
||||
ebs.VolumeSize = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if v, ok := bd["volume_type"].(string); ok && v != "" {
|
||||
|
@ -346,11 +346,11 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
if v, ok := bd["iops"].(int); ok && v > 0 {
|
||||
ebs.IOPS = aws.Integer(v)
|
||||
ebs.IOPS = aws.Long(int64(v))
|
||||
}
|
||||
|
||||
if dn, err := fetchRootDeviceName(d.Get("image_id").(string), ec2conn); err == nil {
|
||||
blockDevices = append(blockDevices, autoscaling.BlockDeviceMapping{
|
||||
blockDevices = append(blockDevices, &autoscaling.BlockDeviceMapping{
|
||||
DeviceName: dn,
|
||||
EBS: ebs,
|
||||
})
|
||||
|
@ -364,23 +364,25 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
|
|||
createLaunchConfigurationOpts.BlockDeviceMappings = blockDevices
|
||||
}
|
||||
|
||||
var id string
|
||||
if v, ok := d.GetOk("name"); ok {
|
||||
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(v.(string))
|
||||
d.SetId(d.Get("name").(string))
|
||||
id = v.(string)
|
||||
} else {
|
||||
hash := sha1.Sum([]byte(fmt.Sprintf("%#v", createLaunchConfigurationOpts)))
|
||||
config_name := fmt.Sprintf("terraform-%s", base64.URLEncoding.EncodeToString(hash[:]))
|
||||
log.Printf("[DEBUG] Computed Launch config name: %s", config_name)
|
||||
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(config_name)
|
||||
d.SetId(config_name)
|
||||
configName := fmt.Sprintf("terraform-%s", base64.URLEncoding.EncodeToString(hash[:]))
|
||||
log.Printf("[DEBUG] Computed Launch config name: %s", configName)
|
||||
id = configName
|
||||
}
|
||||
createLaunchConfigurationOpts.LaunchConfigurationName = aws.String(id)
|
||||
|
||||
log.Printf("[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts)
|
||||
err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)
|
||||
log.Printf(
|
||||
"[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts)
|
||||
_, err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating launch configuration: %s", err)
|
||||
}
|
||||
|
||||
d.SetId(id)
|
||||
log.Printf("[INFO] launch configuration ID: %s", d.Id())
|
||||
|
||||
// We put a Retry here since sometimes eventual consistency bites
|
||||
|
@ -394,8 +396,8 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}
|
|||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
describeOpts := autoscaling.LaunchConfigurationNamesType{
|
||||
LaunchConfigurationNames: []string{d.Id()},
|
||||
describeOpts := autoscaling.DescribeLaunchConfigurationsInput{
|
||||
LaunchConfigurationNames: []*string{aws.String(d.Id())},
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] launch configuration describe configuration: %#v", describeOpts)
|
||||
|
@ -427,7 +429,7 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}
|
|||
d.Set("spot_price", lc.SpotPrice)
|
||||
d.Set("security_groups", lc.SecurityGroups)
|
||||
|
||||
if err := readLCBlockDevices(d, &lc, ec2conn); err != nil {
|
||||
if err := readLCBlockDevices(d, lc, ec2conn); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -438,8 +440,10 @@ func resourceAwsLaunchConfigurationDelete(d *schema.ResourceData, meta interface
|
|||
autoscalingconn := meta.(*AWSClient).autoscalingconn
|
||||
|
||||
log.Printf("[DEBUG] Launch Configuration destroy: %v", d.Id())
|
||||
err := autoscalingconn.DeleteLaunchConfiguration(
|
||||
&autoscaling.LaunchConfigurationNameType{LaunchConfigurationName: aws.String(d.Id())})
|
||||
_, err := autoscalingconn.DeleteLaunchConfiguration(
|
||||
&autoscaling.DeleteLaunchConfigurationInput{
|
||||
LaunchConfigurationName: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
autoscalingerr, ok := err.(aws.APIError)
|
||||
if ok && autoscalingerr.Code == "InvalidConfiguration.NotFound" {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -107,8 +107,8 @@ func testAccCheckAWSLaunchConfigurationDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
describe, err := conn.DescribeLaunchConfigurations(
|
||||
&autoscaling.LaunchConfigurationNamesType{
|
||||
LaunchConfigurationNames: []string{rs.Primary.ID},
|
||||
&autoscaling.DescribeLaunchConfigurationsInput{
|
||||
LaunchConfigurationNames: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
@ -146,7 +146,7 @@ func testAccCheckAWSLaunchConfigurationAttributes(conf *autoscaling.LaunchConfig
|
|||
}
|
||||
|
||||
// Map out the block devices by name, which should be unique.
|
||||
blockDevices := make(map[string]autoscaling.BlockDeviceMapping)
|
||||
blockDevices := make(map[string]*autoscaling.BlockDeviceMapping)
|
||||
for _, blockDevice := range conf.BlockDeviceMappings {
|
||||
blockDevices[*blockDevice.DeviceName] = blockDevice
|
||||
}
|
||||
|
@ -188,8 +188,8 @@ func testAccCheckAWSLaunchConfigurationExists(n string, res *autoscaling.LaunchC
|
|||
|
||||
conn := testAccProvider.Meta().(*AWSClient).autoscalingconn
|
||||
|
||||
describeOpts := autoscaling.LaunchConfigurationNamesType{
|
||||
LaunchConfigurationNames: []string{rs.Primary.ID},
|
||||
describeOpts := autoscaling.DescribeLaunchConfigurationsInput{
|
||||
LaunchConfigurationNames: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
describe, err := conn.DescribeLaunchConfigurations(&describeOpts)
|
||||
|
||||
|
@ -202,7 +202,7 @@ func testAccCheckAWSLaunchConfigurationExists(n string, res *autoscaling.LaunchC
|
|||
return fmt.Errorf("Launch Configuration Group not found")
|
||||
}
|
||||
|
||||
*res = describe.LaunchConfigurations[0]
|
||||
*res = *describe.LaunchConfigurations[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -40,18 +40,18 @@ func resourceAwsMainRouteTableAssociation() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsMainRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
vpcId := d.Get("vpc_id").(string)
|
||||
routeTableId := d.Get("route_table_id").(string)
|
||||
|
||||
log.Printf("[INFO] Creating main route table association: %s => %s", vpcId, routeTableId)
|
||||
|
||||
mainAssociation, err := findMainRouteTableAssociation(ec2conn, vpcId)
|
||||
mainAssociation, err := findMainRouteTableAssociation(conn, vpcId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := ec2conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationRequest{
|
||||
resp, err := conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationInput{
|
||||
AssociationID: mainAssociation.RouteTableAssociationID,
|
||||
RouteTableID: aws.String(routeTableId),
|
||||
})
|
||||
|
@ -67,10 +67,10 @@ func resourceAwsMainRouteTableAssociationCreate(d *schema.ResourceData, meta int
|
|||
}
|
||||
|
||||
func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
mainAssociation, err := findMainRouteTableAssociation(
|
||||
ec2conn,
|
||||
conn,
|
||||
d.Get("vpc_id").(string))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -88,13 +88,13 @@ func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta inter
|
|||
// original_route_table_id - this needs to stay recorded as the AWS-created
|
||||
// table from VPC creation.
|
||||
func resourceAwsMainRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
vpcId := d.Get("vpc_id").(string)
|
||||
routeTableId := d.Get("route_table_id").(string)
|
||||
|
||||
log.Printf("[INFO] Updating main route table association: %s => %s", vpcId, routeTableId)
|
||||
|
||||
resp, err := ec2conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationRequest{
|
||||
resp, err := conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationInput{
|
||||
AssociationID: aws.String(d.Id()),
|
||||
RouteTableID: aws.String(routeTableId),
|
||||
})
|
||||
|
@ -109,7 +109,7 @@ func resourceAwsMainRouteTableAssociationUpdate(d *schema.ResourceData, meta int
|
|||
}
|
||||
|
||||
func resourceAwsMainRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
vpcId := d.Get("vpc_id").(string)
|
||||
originalRouteTableId := d.Get("original_route_table_id").(string)
|
||||
|
||||
|
@ -117,7 +117,7 @@ func resourceAwsMainRouteTableAssociationDelete(d *schema.ResourceData, meta int
|
|||
vpcId,
|
||||
originalRouteTableId)
|
||||
|
||||
resp, err := ec2conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationRequest{
|
||||
resp, err := conn.ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationInput{
|
||||
AssociationID: aws.String(d.Id()),
|
||||
RouteTableID: aws.String(originalRouteTableId),
|
||||
})
|
||||
|
@ -130,31 +130,31 @@ func resourceAwsMainRouteTableAssociationDelete(d *schema.ResourceData, meta int
|
|||
return nil
|
||||
}
|
||||
|
||||
func findMainRouteTableAssociation(ec2conn *ec2.EC2, vpcId string) (*ec2.RouteTableAssociation, error) {
|
||||
mainRouteTable, err := findMainRouteTable(ec2conn, vpcId)
|
||||
func findMainRouteTableAssociation(conn *ec2.EC2, vpcId string) (*ec2.RouteTableAssociation, error) {
|
||||
mainRouteTable, err := findMainRouteTable(conn, vpcId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, a := range mainRouteTable.Associations {
|
||||
if *a.Main {
|
||||
return &a, nil
|
||||
return a, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Could not find main routing table association for VPC: %s", vpcId)
|
||||
}
|
||||
|
||||
func findMainRouteTable(ec2conn *ec2.EC2, vpcId string) (*ec2.RouteTable, error) {
|
||||
mainFilter := ec2.Filter{
|
||||
aws.String("association.main"),
|
||||
[]string{"true"},
|
||||
func findMainRouteTable(conn *ec2.EC2, vpcId string) (*ec2.RouteTable, error) {
|
||||
mainFilter := &ec2.Filter{
|
||||
Name: aws.String("association.main"),
|
||||
Values: []*string{aws.String("true")},
|
||||
}
|
||||
vpcFilter := ec2.Filter{
|
||||
aws.String("vpc-id"),
|
||||
[]string{vpcId},
|
||||
vpcFilter := &ec2.Filter{
|
||||
Name: aws.String("vpc-id"),
|
||||
Values: []*string{aws.String(vpcId)},
|
||||
}
|
||||
routeResp, err := ec2conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
Filters: []ec2.Filter{mainFilter, vpcFilter},
|
||||
routeResp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
Filters: []*ec2.Filter{mainFilter, vpcFilter},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -165,5 +165,5 @@ func findMainRouteTable(ec2conn *ec2.EC2, vpcId string) (*ec2.RouteTable, error)
|
|||
len(routeResp.RouteTables))
|
||||
}
|
||||
|
||||
return &routeResp.RouteTables[0], nil
|
||||
return routeResp.RouteTables[0], nil
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func resourceAwsNetworkAcl() *schema.Resource {
|
|||
|
||||
func resourceAwsNetworkAclCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Create the Network Acl
|
||||
createOpts := &ec2.CreateNetworkACLInput{
|
||||
|
@ -132,7 +132,7 @@ func resourceAwsNetworkAclCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsNetworkAclRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsInput{
|
||||
NetworkACLIDs: []*string{aws.String(d.Id())},
|
||||
|
@ -167,7 +167,7 @@ func resourceAwsNetworkAclRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsNetworkAclUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
d.Partial(true)
|
||||
|
||||
if d.HasChange("ingress") {
|
||||
|
@ -265,7 +265,7 @@ func updateNetworkAclEntries(d *schema.ResourceData, entryType string, conn *ec2
|
|||
}
|
||||
|
||||
func resourceAwsNetworkAclDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[INFO] Deleting Network Acl: %s", d.Id())
|
||||
return resource.Retry(5*time.Minute, func() error {
|
||||
|
|
|
@ -4,12 +4,10 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
// "github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
// "github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSNetworkAcl_EgressAndIngressRules(t *testing.T) {
|
||||
|
@ -151,7 +149,7 @@ func TestAccAWSNetworkAcl_OnlyEgressRules(t *testing.T) {
|
|||
Config: testAccAWSNetworkAclEgressConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSNetworkAclExists("aws_network_acl.bond", &networkAcl),
|
||||
testAccCheckTags(&networkAcl.Tags, "foo", "bar"),
|
||||
testAccCheckTagsSDK(&networkAcl.Tags, "foo", "bar"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -192,8 +190,8 @@ func testAccCheckAWSNetworkAclDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Retrieve the network acl
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||
NetworkACLIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsInput{
|
||||
NetworkACLIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
if len(resp.NetworkACLs) > 0 && *resp.NetworkACLs[0].NetworkACLID == rs.Primary.ID {
|
||||
|
@ -228,15 +226,15 @@ func testAccCheckAWSNetworkAclExists(n string, networkAcl *ec2.NetworkACL) resou
|
|||
}
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||
NetworkACLIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsInput{
|
||||
NetworkACLIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(resp.NetworkACLs) > 0 && *resp.NetworkACLs[0].NetworkACLID == rs.Primary.ID {
|
||||
*networkAcl = resp.NetworkACLs[0]
|
||||
*networkAcl = *resp.NetworkACLs[0]
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -246,7 +244,7 @@ func testAccCheckAWSNetworkAclExists(n string, networkAcl *ec2.NetworkACL) resou
|
|||
|
||||
func testIngressRuleLength(networkAcl *ec2.NetworkACL, length int) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
var ingressEntries []ec2.NetworkACLEntry
|
||||
var ingressEntries []*ec2.NetworkACLEntry
|
||||
for _, e := range networkAcl.Entries {
|
||||
if *e.Egress == false {
|
||||
ingressEntries = append(ingressEntries, e)
|
||||
|
@ -267,12 +265,12 @@ func testAccCheckSubnetIsAssociatedWithAcl(acl string, sub string) resource.Test
|
|||
subnet := s.RootModule().Resources[sub]
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
||||
Filters: []ec2.Filter{
|
||||
ec2.Filter{
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsInput{
|
||||
NetworkACLIDs: []*string{aws.String(networkAcl.Primary.ID)},
|
||||
Filters: []*ec2.Filter{
|
||||
&ec2.Filter{
|
||||
Name: aws.String("association.subnet-id"),
|
||||
Values: []string{subnet.Primary.ID},
|
||||
Values: []*string{aws.String(subnet.Primary.ID)},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -297,12 +295,12 @@ func testAccCheckSubnetIsNotAssociatedWithAcl(acl string, subnet string) resourc
|
|||
subnet := s.RootModule().Resources[subnet]
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsRequest{
|
||||
NetworkACLIDs: []string{networkAcl.Primary.ID},
|
||||
Filters: []ec2.Filter{
|
||||
ec2.Filter{
|
||||
resp, err := conn.DescribeNetworkACLs(&ec2.DescribeNetworkACLsInput{
|
||||
NetworkACLIDs: []*string{aws.String(networkAcl.Primary.ID)},
|
||||
Filters: []*ec2.Filter{
|
||||
&ec2.Filter{
|
||||
Name: aws.String("association.subnet-id"),
|
||||
Values: []string{subnet.Primary.ID},
|
||||
Values: []*string{aws.String(subnet.Primary.ID)},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -78,12 +78,12 @@ func resourceAwsNetworkInterface() *schema.Resource {
|
|||
|
||||
func resourceAwsNetworkInterfaceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
request := &ec2.CreateNetworkInterfaceInput{
|
||||
Groups: expandStringListSDK(d.Get("security_groups").(*schema.Set).List()),
|
||||
Groups: expandStringList(d.Get("security_groups").(*schema.Set).List()),
|
||||
SubnetID: aws.String(d.Get("subnet_id").(string)),
|
||||
PrivateIPAddresses: expandPrivateIPAddessesSDK(d.Get("private_ips").(*schema.Set).List()),
|
||||
PrivateIPAddresses: expandPrivateIPAddesses(d.Get("private_ips").(*schema.Set).List()),
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating network interface")
|
||||
|
@ -99,7 +99,7 @@ func resourceAwsNetworkInterfaceCreate(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceAwsNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) error {
|
||||
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
describe_network_interfaces_request := &ec2.DescribeNetworkInterfacesInput{
|
||||
NetworkInterfaceIDs: []*string{aws.String(d.Id())},
|
||||
}
|
||||
|
@ -120,14 +120,14 @@ func resourceAwsNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e
|
|||
|
||||
eni := describeResp.NetworkInterfaces[0]
|
||||
d.Set("subnet_id", eni.SubnetID)
|
||||
d.Set("private_ips", flattenNetworkInterfacesPrivateIPAddessesSDK(eni.PrivateIPAddresses))
|
||||
d.Set("security_groups", flattenGroupIdentifiersSDK(eni.Groups))
|
||||
d.Set("private_ips", flattenNetworkInterfacesPrivateIPAddesses(eni.PrivateIPAddresses))
|
||||
d.Set("security_groups", flattenGroupIdentifiers(eni.Groups))
|
||||
|
||||
// Tags
|
||||
d.Set("tags", tagsToMapSDK(eni.TagSet))
|
||||
|
||||
if eni.Attachment != nil {
|
||||
attachment := []map[string]interface{}{flattenAttachmentSDK(eni.Attachment)}
|
||||
attachment := []map[string]interface{}{flattenAttachment(eni.Attachment)}
|
||||
d.Set("attachment", attachment)
|
||||
} else {
|
||||
d.Set("attachment", nil)
|
||||
|
@ -164,7 +164,7 @@ func resourceAwsNetworkInterfaceDetach(oa *schema.Set, meta interface{}, eniId s
|
|||
AttachmentID: aws.String(old_attachment["attachment_id"].(string)),
|
||||
Force: aws.Boolean(true),
|
||||
}
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
_, detach_err := conn.DetachNetworkInterface(detach_request)
|
||||
if detach_err != nil {
|
||||
return fmt.Errorf("Error detaching ENI: %s", detach_err)
|
||||
|
@ -187,7 +187,7 @@ func resourceAwsNetworkInterfaceDetach(oa *schema.Set, meta interface{}, eniId s
|
|||
}
|
||||
|
||||
func resourceAwsNetworkInterfaceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
d.Partial(true)
|
||||
|
||||
if d.HasChange("attachment") {
|
||||
|
@ -219,7 +219,7 @@ func resourceAwsNetworkInterfaceUpdate(d *schema.ResourceData, meta interface{})
|
|||
if d.HasChange("security_groups") {
|
||||
request := &ec2.ModifyNetworkInterfaceAttributeInput{
|
||||
NetworkInterfaceID: aws.String(d.Id()),
|
||||
Groups: expandStringListSDK(d.Get("security_groups").(*schema.Set).List()),
|
||||
Groups: expandStringList(d.Get("security_groups").(*schema.Set).List()),
|
||||
}
|
||||
|
||||
_, err := conn.ModifyNetworkInterfaceAttribute(request)
|
||||
|
@ -242,7 +242,7 @@ func resourceAwsNetworkInterfaceUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceAwsNetworkInterfaceDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[INFO] Deleting ENI: %s", d.Id())
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ func testAccCheckAWSENIExists(n string, res *ec2.NetworkInterface) resource.Test
|
|||
return fmt.Errorf("No ENI ID is set")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
describe_network_interfaces_request := &ec2.DescribeNetworkInterfacesInput{
|
||||
NetworkInterfaceIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func testAccCheckAWSENIDestroy(s *terraform.State) error {
|
|||
continue
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
describe_network_interfaces_request := &ec2.DescribeNetworkInterfacesInput{
|
||||
NetworkInterfaceIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func resourceAwsRoute53Record() *schema.Resource {
|
||||
|
@ -74,7 +74,7 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
|||
conn := meta.(*AWSClient).r53conn
|
||||
zone := cleanZoneID(d.Get("zone_id").(string))
|
||||
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(zone)})
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(zone)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -90,15 +90,15 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
|||
// operation happening at the same time.
|
||||
changeBatch := &route53.ChangeBatch{
|
||||
Comment: aws.String("Managed by Terraform"),
|
||||
Changes: []route53.Change{
|
||||
route53.Change{
|
||||
Changes: []*route53.Change{
|
||||
&route53.Change{
|
||||
Action: aws.String("UPSERT"),
|
||||
ResourceRecordSet: rec,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
req := &route53.ChangeResourceRecordSetsRequest{
|
||||
req := &route53.ChangeResourceRecordSetsInput{
|
||||
HostedZoneID: aws.String(cleanZoneID(*zoneRecord.HostedZone.ID)),
|
||||
ChangeBatch: changeBatch,
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
changeInfo := respRaw.(*route53.ChangeResourceRecordSetsResponse).ChangeInfo
|
||||
changeInfo := respRaw.(*route53.ChangeResourceRecordSetsOutput).ChangeInfo
|
||||
|
||||
// Generate an ID
|
||||
d.SetId(fmt.Sprintf("%s_%s_%s", zone, d.Get("name").(string), d.Get("type").(string)))
|
||||
|
@ -146,7 +146,7 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
|||
Timeout: 30 * time.Minute,
|
||||
MinTimeout: 5 * time.Second,
|
||||
Refresh: func() (result interface{}, state string, err error) {
|
||||
changeRequest := &route53.GetChangeRequest{
|
||||
changeRequest := &route53.GetChangeInput{
|
||||
ID: aws.String(cleanChangeID(*changeInfo.ID)),
|
||||
}
|
||||
return resourceAwsGoRoute53Wait(conn, changeRequest)
|
||||
|
@ -166,13 +166,13 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
|||
zone := cleanZoneID(d.Get("zone_id").(string))
|
||||
|
||||
// get expanded name
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(zone)})
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(zone)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
en := expandRecordName(d.Get("name").(string), *zoneRecord.HostedZone.Name)
|
||||
|
||||
lopts := &route53.ListResourceRecordSetsRequest{
|
||||
lopts := &route53.ListResourceRecordSetsInput{
|
||||
HostedZoneID: aws.String(cleanZoneID(zone)),
|
||||
StartRecordName: aws.String(en),
|
||||
StartRecordType: aws.String(d.Get("type").(string)),
|
||||
|
@ -218,7 +218,7 @@ func resourceAwsRoute53RecordDelete(d *schema.ResourceData, meta interface{}) er
|
|||
zone := cleanZoneID(d.Get("zone_id").(string))
|
||||
log.Printf("[DEBUG] Deleting resource records for zone: %s, name: %s",
|
||||
zone, d.Get("name").(string))
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(zone)})
|
||||
zoneRecord, err := conn.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(zone)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -231,15 +231,15 @@ func resourceAwsRoute53RecordDelete(d *schema.ResourceData, meta interface{}) er
|
|||
// Create the new records
|
||||
changeBatch := &route53.ChangeBatch{
|
||||
Comment: aws.String("Deleted by Terraform"),
|
||||
Changes: []route53.Change{
|
||||
route53.Change{
|
||||
Changes: []*route53.Change{
|
||||
&route53.Change{
|
||||
Action: aws.String("DELETE"),
|
||||
ResourceRecordSet: rec,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
req := &route53.ChangeResourceRecordSetsRequest{
|
||||
req := &route53.ChangeResourceRecordSetsInput{
|
||||
HostedZoneID: aws.String(cleanZoneID(zone)),
|
||||
ChangeBatch: changeBatch,
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
route53 "github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func TestCleanRecordName(t *testing.T) {
|
||||
|
@ -134,7 +134,7 @@ func testAccCheckRoute53RecordDestroy(s *terraform.State) error {
|
|||
name := parts[1]
|
||||
rType := parts[2]
|
||||
|
||||
lopts := &route53.ListResourceRecordSetsRequest{
|
||||
lopts := &route53.ListResourceRecordSetsInput{
|
||||
HostedZoneID: aws.String(cleanZoneID(zone)),
|
||||
StartRecordName: aws.String(name),
|
||||
StartRecordType: aws.String(rType),
|
||||
|
@ -174,7 +174,7 @@ func testAccCheckRoute53RecordExists(n string) resource.TestCheckFunc {
|
|||
|
||||
en := expandRecordName(name, "notexample.com")
|
||||
|
||||
lopts := &route53.ListResourceRecordSetsRequest{
|
||||
lopts := &route53.ListResourceRecordSetsInput{
|
||||
HostedZoneID: aws.String(cleanZoneID(zone)),
|
||||
StartRecordName: aws.String(en),
|
||||
StartRecordType: aws.String(rType),
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func resourceAwsRoute53Zone() *schema.Resource {
|
||||
|
@ -51,7 +51,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
r53 := meta.(*AWSClient).r53conn
|
||||
|
||||
comment := &route53.HostedZoneConfig{Comment: aws.String("Managed by Terraform")}
|
||||
req := &route53.CreateHostedZoneRequest{
|
||||
req := &route53.CreateHostedZoneInput{
|
||||
Name: aws.String(d.Get("name").(string)),
|
||||
HostedZoneConfig: comment,
|
||||
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
|
||||
|
@ -76,7 +76,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
Timeout: 10 * time.Minute,
|
||||
MinTimeout: 2 * time.Second,
|
||||
Refresh: func() (result interface{}, state string, err error) {
|
||||
changeRequest := &route53.GetChangeRequest{
|
||||
changeRequest := &route53.GetChangeInput{
|
||||
ID: aws.String(cleanChangeID(*resp.ChangeInfo.ID)),
|
||||
}
|
||||
return resourceAwsGoRoute53Wait(r53, changeRequest)
|
||||
|
@ -91,7 +91,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error {
|
||||
r53 := meta.(*AWSClient).r53conn
|
||||
zone, err := r53.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(d.Id())})
|
||||
zone, err := r53.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(d.Id())})
|
||||
if err != nil {
|
||||
// Handle a deleted zone
|
||||
if r53err, ok := err.(aws.APIError); ok && r53err.Code == "NoSuchHostedZone" {
|
||||
|
@ -101,13 +101,16 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
|
|||
return err
|
||||
}
|
||||
|
||||
ns := zone.DelegationSet.NameServers
|
||||
ns := make([]string, len(zone.DelegationSet.NameServers))
|
||||
for i := range zone.DelegationSet.NameServers {
|
||||
ns[i] = *zone.DelegationSet.NameServers[i]
|
||||
}
|
||||
if err := d.Set("name_servers", ns); err != nil {
|
||||
return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err)
|
||||
}
|
||||
|
||||
// get tags
|
||||
req := &route53.ListTagsForResourceRequest{
|
||||
req := &route53.ListTagsForResourceInput{
|
||||
ResourceID: aws.String(d.Id()),
|
||||
ResourceType: aws.String("hostedzone"),
|
||||
}
|
||||
|
@ -117,7 +120,7 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
|
|||
return err
|
||||
}
|
||||
|
||||
var tags []route53.Tag
|
||||
var tags []*route53.Tag
|
||||
if resp.ResourceTagSet != nil {
|
||||
tags = resp.ResourceTagSet.Tags
|
||||
}
|
||||
|
@ -146,7 +149,7 @@ func resourceAwsRoute53ZoneDelete(d *schema.ResourceData, meta interface{}) erro
|
|||
|
||||
log.Printf("[DEBUG] Deleting Route53 hosted zone: %s (ID: %s)",
|
||||
d.Get("name").(string), d.Id())
|
||||
_, err := r53.DeleteHostedZone(&route53.DeleteHostedZoneRequest{ID: aws.String(d.Id())})
|
||||
_, err := r53.DeleteHostedZone(&route53.DeleteHostedZoneInput{ID: aws.String(d.Id())})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -154,7 +157,7 @@ func resourceAwsRoute53ZoneDelete(d *schema.ResourceData, meta interface{}) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsGoRoute53Wait(r53 *route53.Route53, ref *route53.GetChangeRequest) (result interface{}, state string, err error) {
|
||||
func resourceAwsGoRoute53Wait(r53 *route53.Route53, ref *route53.GetChangeInput) (result interface{}, state string, err error) {
|
||||
|
||||
status, err := r53.GetChange(ref)
|
||||
if err != nil {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func TestCleanPrefix(t *testing.T) {
|
||||
|
@ -91,7 +91,7 @@ func testAccCheckRoute53ZoneDestroy(s *terraform.State) error {
|
|||
continue
|
||||
}
|
||||
|
||||
_, err := conn.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(rs.Primary.ID)})
|
||||
_, err := conn.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(rs.Primary.ID)})
|
||||
if err == nil {
|
||||
return fmt.Errorf("Hosted zone still exists")
|
||||
}
|
||||
|
@ -111,15 +111,15 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource.
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).r53conn
|
||||
resp, err := conn.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(rs.Primary.ID)})
|
||||
resp, err := conn.GetHostedZone(&route53.GetHostedZoneInput{ID: aws.String(rs.Primary.ID)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Hosted zone err: %v", err)
|
||||
}
|
||||
|
||||
for _, ns := range resp.DelegationSet.NameServers {
|
||||
attribute := fmt.Sprintf("name_servers.%d", hashcode.String(ns))
|
||||
attribute := fmt.Sprintf("name_servers.%d", hashcode.String(*ns))
|
||||
dsns := rs.Primary.Attributes[attribute]
|
||||
if dsns != ns {
|
||||
if dsns != *ns {
|
||||
return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns)
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ func testAccLoadTagsR53(zone *route53.HostedZone, td *route53.ResourceTagSet) re
|
|||
conn := testAccProvider.Meta().(*AWSClient).r53conn
|
||||
|
||||
zone := cleanZoneID(*zone.ID)
|
||||
req := &route53.ListTagsForResourceRequest{
|
||||
req := &route53.ListTagsForResourceInput{
|
||||
ResourceID: aws.String(zone),
|
||||
ResourceType: aws.String("hostedzone"),
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -62,15 +62,15 @@ func resourceAwsRouteTable() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Create the routing table
|
||||
createOpts := &ec2.CreateRouteTableRequest{
|
||||
createOpts := &ec2.CreateRouteTableInput{
|
||||
VPCID: aws.String(d.Get("vpc_id").(string)),
|
||||
}
|
||||
log.Printf("[DEBUG] RouteTable create config: %#v", createOpts)
|
||||
|
||||
resp, err := ec2conn.CreateRouteTable(createOpts)
|
||||
resp, err := conn.CreateRouteTable(createOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating route table: %s", err)
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending"},
|
||||
Target: "ready",
|
||||
Refresh: resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id()),
|
||||
Refresh: resourceAwsRouteTableStateRefreshFunc(conn, d.Id()),
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -100,9 +100,9 @@ func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id())()
|
||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -147,13 +147,13 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("route", route)
|
||||
|
||||
// Tags
|
||||
d.Set("tags", tagsToMap(rt.Tags))
|
||||
d.Set("tags", tagsToMapSDK(rt.Tags))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Check if the route set as a whole has changed
|
||||
if d.HasChange("route") {
|
||||
|
@ -169,7 +169,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
log.Printf(
|
||||
"[INFO] Deleting route from %s: %s",
|
||||
d.Id(), m["cidr_block"].(string))
|
||||
err := ec2conn.DeleteRoute(&ec2.DeleteRouteRequest{
|
||||
_, err := conn.DeleteRoute(&ec2.DeleteRouteInput{
|
||||
RouteTableID: aws.String(d.Id()),
|
||||
DestinationCIDRBlock: aws.String(m["cidr_block"].(string)),
|
||||
})
|
||||
|
@ -186,7 +186,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
for _, route := range nrs.List() {
|
||||
m := route.(map[string]interface{})
|
||||
|
||||
opts := ec2.CreateRouteRequest{
|
||||
opts := ec2.CreateRouteInput{
|
||||
RouteTableID: aws.String(d.Id()),
|
||||
DestinationCIDRBlock: aws.String(m["cidr_block"].(string)),
|
||||
GatewayID: aws.String(m["gateway_id"].(string)),
|
||||
|
@ -195,7 +195,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
log.Printf("[INFO] Creating route for %s: %#v", d.Id(), opts)
|
||||
if err := ec2conn.CreateRoute(&opts); err != nil {
|
||||
if _, err := conn.CreateRoute(&opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
}
|
||||
|
||||
if err := setTags(ec2conn, d); err != nil {
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
|
@ -214,11 +214,11 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// First request the routing table since we'll have to disassociate
|
||||
// all the subnets first.
|
||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id())()
|
||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error
|
|||
// Do all the disassociations
|
||||
for _, a := range rt.Associations {
|
||||
log.Printf("[INFO] Disassociating association: %s", *a.RouteTableAssociationID)
|
||||
err := ec2conn.DisassociateRouteTable(&ec2.DisassociateRouteTableRequest{
|
||||
_, err := conn.DisassociateRouteTable(&ec2.DisassociateRouteTableInput{
|
||||
AssociationID: a.RouteTableAssociationID,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -240,7 +240,7 @@ func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
// Delete the route table
|
||||
log.Printf("[INFO] Deleting Route Table: %s", d.Id())
|
||||
err = ec2conn.DeleteRouteTable(&ec2.DeleteRouteTableRequest{
|
||||
_, err = conn.DeleteRouteTable(&ec2.DeleteRouteTableInput{
|
||||
RouteTableID: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -260,7 +260,7 @@ func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"ready"},
|
||||
Target: "",
|
||||
Refresh: resourceAwsRouteTableStateRefreshFunc(ec2conn, d.Id()),
|
||||
Refresh: resourceAwsRouteTableStateRefreshFunc(conn, d.Id()),
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -296,8 +296,8 @@ func resourceAwsRouteTableHash(v interface{}) int {
|
|||
// a RouteTable.
|
||||
func resourceAwsRouteTableStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
||||
return func() (interface{}, string, error) {
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
RouteTableIDs: []string{id},
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
RouteTableIDs: []*string{aws.String(id)},
|
||||
})
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidRouteTableID.NotFound" {
|
||||
|
@ -314,7 +314,7 @@ func resourceAwsRouteTableStateRefreshFunc(conn *ec2.EC2, id string) resource.St
|
|||
return nil, "", nil
|
||||
}
|
||||
|
||||
rt := &resp.RouteTables[0]
|
||||
rt := resp.RouteTables[0]
|
||||
return rt, "ready", nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -32,14 +32,14 @@ func resourceAwsRouteTableAssociation() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf(
|
||||
"[INFO] Creating route table association: %s => %s",
|
||||
d.Get("subnet_id").(string),
|
||||
d.Get("route_table_id").(string))
|
||||
|
||||
resp, err := ec2conn.AssociateRouteTable(&ec2.AssociateRouteTableRequest{
|
||||
resp, err := conn.AssociateRouteTable(&ec2.AssociateRouteTableInput{
|
||||
RouteTableID: aws.String(d.Get("route_table_id").(string)),
|
||||
SubnetID: aws.String(d.Get("subnet_id").(string)),
|
||||
})
|
||||
|
@ -56,11 +56,11 @@ func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableAssociationRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Get the routing table that this association belongs to
|
||||
rtRaw, _, err := resourceAwsRouteTableStateRefreshFunc(
|
||||
ec2conn, d.Get("route_table_id").(string))()
|
||||
conn, d.Get("route_table_id").(string))()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,18 +88,18 @@ func resourceAwsRouteTableAssociationRead(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf(
|
||||
"[INFO] Creating route table association: %s => %s",
|
||||
d.Get("subnet_id").(string),
|
||||
d.Get("route_table_id").(string))
|
||||
|
||||
req := &ec2.ReplaceRouteTableAssociationRequest{
|
||||
req := &ec2.ReplaceRouteTableAssociationInput{
|
||||
AssociationID: aws.String(d.Id()),
|
||||
RouteTableID: aws.String(d.Get("route_table_id").(string)),
|
||||
}
|
||||
resp, err := ec2conn.ReplaceRouteTableAssociation(req)
|
||||
resp, err := conn.ReplaceRouteTableAssociation(req)
|
||||
|
||||
if err != nil {
|
||||
ec2err, ok := err.(aws.APIError)
|
||||
|
@ -119,10 +119,10 @@ func resourceAwsRouteTableAssociationUpdate(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceAwsRouteTableAssociationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[INFO] Deleting route table association: %s", d.Id())
|
||||
err := ec2conn.DisassociateRouteTable(&ec2.DisassociateRouteTableRequest{
|
||||
_, err := conn.DisassociateRouteTable(&ec2.DisassociateRouteTableInput{
|
||||
AssociationID: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -46,8 +46,8 @@ func testAccCheckRouteTableAssociationDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find the resource
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
RouteTableIDs: []string{rs.Primary.Attributes["route_table_id"]},
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
RouteTableIDs: []*string{aws.String(rs.Primary.Attributes["route_table_id"])},
|
||||
})
|
||||
if err != nil {
|
||||
// Verify the error is what we want
|
||||
|
@ -84,8 +84,8 @@ func testAccCheckRouteTableAssociationExists(n string, v *ec2.RouteTable) resour
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
RouteTableIDs: []string{rs.Primary.Attributes["route_table_id"]},
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
RouteTableIDs: []*string{aws.String(rs.Primary.Attributes["route_table_id"])},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -94,7 +94,7 @@ func testAccCheckRouteTableAssociationExists(n string, v *ec2.RouteTable) resour
|
|||
return fmt.Errorf("RouteTable not found")
|
||||
}
|
||||
|
||||
*v = resp.RouteTables[0]
|
||||
*v = *resp.RouteTables[0]
|
||||
|
||||
if len(v.Associations) == 0 {
|
||||
return fmt.Errorf("no associations")
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ func TestAccAWSRouteTable_normal(t *testing.T) {
|
|||
return fmt.Errorf("bad routes: %#v", v.Routes)
|
||||
}
|
||||
|
||||
routes := make(map[string]ec2.Route)
|
||||
routes := make(map[string]*ec2.Route)
|
||||
for _, r := range v.Routes {
|
||||
routes[*r.DestinationCIDRBlock] = r
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func TestAccAWSRouteTable_normal(t *testing.T) {
|
|||
return fmt.Errorf("bad routes: %#v", v.Routes)
|
||||
}
|
||||
|
||||
routes := make(map[string]ec2.Route)
|
||||
routes := make(map[string]*ec2.Route)
|
||||
for _, r := range v.Routes {
|
||||
routes[*r.DestinationCIDRBlock] = r
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func TestAccAWSRouteTable_instance(t *testing.T) {
|
|||
return fmt.Errorf("bad routes: %#v", v.Routes)
|
||||
}
|
||||
|
||||
routes := make(map[string]ec2.Route)
|
||||
routes := make(map[string]*ec2.Route)
|
||||
for _, r := range v.Routes {
|
||||
routes[*r.DestinationCIDRBlock] = r
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ func TestAccAWSRouteTable_tags(t *testing.T) {
|
|||
Config: testAccRouteTableConfigTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckRouteTableExists("aws_route_table.foo", &route_table),
|
||||
testAccCheckTags(&route_table.Tags, "foo", "bar"),
|
||||
testAccCheckTagsSDK(&route_table.Tags, "foo", "bar"),
|
||||
),
|
||||
},
|
||||
|
||||
|
@ -142,8 +142,8 @@ func TestAccAWSRouteTable_tags(t *testing.T) {
|
|||
Config: testAccRouteTableConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckRouteTableExists("aws_route_table.foo", &route_table),
|
||||
testAccCheckTags(&route_table.Tags, "foo", ""),
|
||||
testAccCheckTags(&route_table.Tags, "bar", "baz"),
|
||||
testAccCheckTagsSDK(&route_table.Tags, "foo", ""),
|
||||
testAccCheckTagsSDK(&route_table.Tags, "bar", "baz"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -159,8 +159,8 @@ func testAccCheckRouteTableDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find the resource
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
RouteTableIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
RouteTableIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
if len(resp.RouteTables) > 0 {
|
||||
|
@ -195,8 +195,8 @@ func testAccCheckRouteTableExists(n string, v *ec2.RouteTable) resource.TestChec
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesRequest{
|
||||
RouteTableIDs: []string{rs.Primary.ID},
|
||||
resp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
|
||||
RouteTableIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -205,7 +205,7 @@ func testAccCheckRouteTableExists(n string, v *ec2.RouteTable) resource.TestChec
|
|||
return fmt.Errorf("RouteTable not found")
|
||||
}
|
||||
|
||||
*v = resp.RouteTables[0]
|
||||
*v = *resp.RouteTables[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ func _TestAccAWSRouteTable_vpcPeering(t *testing.T) {
|
|||
return fmt.Errorf("bad routes: %#v", v.Routes)
|
||||
}
|
||||
|
||||
routes := make(map[string]ec2.Route)
|
||||
routes := make(map[string]*ec2.Route)
|
||||
for _, r := range v.Routes {
|
||||
routes[*r.DestinationCIDRBlock] = r
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/s3"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
func resourceAwsS3Bucket() *schema.Resource {
|
||||
|
@ -46,7 +46,7 @@ func resourceAwsS3BucketCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
log.Printf("[DEBUG] S3 bucket create: %s, ACL: %s", bucket, acl)
|
||||
|
||||
req := &s3.CreateBucketRequest{
|
||||
req := &s3.CreateBucketInput{
|
||||
Bucket: aws.String(bucket),
|
||||
ACL: aws.String(acl),
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func resourceAwsS3BucketUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
||||
s3conn := meta.(*AWSClient).s3conn
|
||||
|
||||
err := s3conn.HeadBucket(&s3.HeadBucketRequest{
|
||||
_, err := s3conn.HeadBucket(&s3.HeadBucketInput{
|
||||
Bucket: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,7 @@ func resourceAwsS3BucketDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
s3conn := meta.(*AWSClient).s3conn
|
||||
|
||||
log.Printf("[DEBUG] S3 Delete Bucket: %s", d.Id())
|
||||
err := s3conn.DeleteBucket(&s3.DeleteBucketRequest{
|
||||
_, err := s3conn.DeleteBucket(&s3.DeleteBucketInput{
|
||||
Bucket: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/s3"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
func TestAccAWSS3Bucket(t *testing.T) {
|
||||
|
@ -37,7 +37,7 @@ func testAccCheckAWSS3BucketDestroy(s *terraform.State) error {
|
|||
if rs.Type != "aws_s3_bucket" {
|
||||
continue
|
||||
}
|
||||
err := conn.DeleteBucket(&s3.DeleteBucketRequest{
|
||||
_, err := conn.DeleteBucket(&s3.DeleteBucketInput{
|
||||
Bucket: aws.String(rs.Primary.ID),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -59,7 +59,7 @@ func testAccCheckAWSS3BucketExists(n string) resource.TestCheckFunc {
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).s3conn
|
||||
err := conn.HeadBucket(&s3.HeadBucketRequest{
|
||||
_, err := conn.HeadBucket(&s3.HeadBucketInput{
|
||||
Bucket: aws.String(rs.Primary.ID),
|
||||
})
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ func resourceAwsSecurityGroup() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
securityGroupOpts := &ec2.CreateSecurityGroupInput{
|
||||
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 {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
sgRaw, _, err := SGStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
|
@ -214,7 +214,7 @@ func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) erro
|
|||
}
|
||||
|
||||
func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
sgRaw, _, err := SGStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
|
@ -249,7 +249,7 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
|
||||
func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[DEBUG] Security Group destroy: %v", d.Id())
|
||||
|
||||
|
@ -355,7 +355,7 @@ func resourceAwsSecurityGroupIPPermGather(d *schema.ResourceData, permissions []
|
|||
|
||||
var groups []string
|
||||
if len(perm.UserIDGroupPairs) > 0 {
|
||||
groups = flattenSecurityGroupsSDK(perm.UserIDGroupPairs)
|
||||
groups = flattenSecurityGroups(perm.UserIDGroupPairs)
|
||||
}
|
||||
for i, id := range groups {
|
||||
if id == d.Id() {
|
||||
|
@ -398,8 +398,8 @@ func resourceAwsSecurityGroupUpdateRules(
|
|||
os := o.(*schema.Set)
|
||||
ns := n.(*schema.Set)
|
||||
|
||||
remove := expandIPPermsSDK(group, os.Difference(ns).List())
|
||||
add := expandIPPermsSDK(group, ns.Difference(os).List())
|
||||
remove := expandIPPerms(group, os.Difference(ns).List())
|
||||
add := expandIPPerms(group, ns.Difference(os).List())
|
||||
|
||||
// TODO: We need to handle partial state better in the in-between
|
||||
// in this update.
|
||||
|
@ -411,7 +411,7 @@ func resourceAwsSecurityGroupUpdateRules(
|
|||
// not have service issues.
|
||||
|
||||
if len(remove) > 0 || len(add) > 0 {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
var err error
|
||||
if len(remove) > 0 {
|
||||
|
|
|
@ -185,7 +185,7 @@ func TestAccAWSSecurityGroup_Change(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckAWSSecurityGroupDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_security_group" {
|
||||
|
@ -229,7 +229,7 @@ func testAccCheckAWSSecurityGroupExists(n string, group *ec2.SecurityGroup) reso
|
|||
return fmt.Errorf("No Security Group is set")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
req := &ec2.DescribeSecurityGroupsInput{
|
||||
GroupIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func resourceAwsSubnet() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
createOpts := &ec2.CreateSubnetInput{
|
||||
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 {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
resp, err := conn.DescribeSubnets(&ec2.DescribeSubnetsInput{
|
||||
SubnetIDs: []*string{aws.String(d.Id())},
|
||||
|
@ -121,7 +121,7 @@ func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
d.Partial(true)
|
||||
|
||||
|
@ -156,7 +156,7 @@ func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsSubnetDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ec2SDKconn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
log.Printf("[INFO] Deleting subnet: %s", d.Id())
|
||||
req := &ec2.DeleteSubnetInput{
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestAccAWSSubnet(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckSubnetDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
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")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := conn.DescribeSubnets(&ec2.DescribeSubnetsInput{
|
||||
SubnetIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -64,18 +64,18 @@ func resourceAwsVpc() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
instance_tenancy := "default"
|
||||
if v, ok := d.GetOk("instance_tenancy"); ok {
|
||||
instance_tenancy = v.(string)
|
||||
}
|
||||
// Create the VPC
|
||||
createOpts := &ec2.CreateVPCRequest{
|
||||
createOpts := &ec2.CreateVPCInput{
|
||||
CIDRBlock: aws.String(d.Get("cidr_block").(string)),
|
||||
InstanceTenancy: aws.String(instance_tenancy),
|
||||
}
|
||||
log.Printf("[DEBUG] VPC create config: %#v", *createOpts)
|
||||
vpcResp, err := ec2conn.CreateVPC(createOpts)
|
||||
vpcResp, err := conn.CreateVPC(createOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating VPC: %s", err)
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending"},
|
||||
Target: "available",
|
||||
Refresh: VPCStateRefreshFunc(ec2conn, d.Id()),
|
||||
Refresh: VPCStateRefreshFunc(conn, d.Id()),
|
||||
Timeout: 10 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -110,10 +110,10 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Refresh the VPC state
|
||||
vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())()
|
||||
vpcRaw, _, err := VPCStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -128,25 +128,25 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("cidr_block", vpc.CIDRBlock)
|
||||
|
||||
// Tags
|
||||
d.Set("tags", tagsToMap(vpc.Tags))
|
||||
d.Set("tags", tagsToMapSDK(vpc.Tags))
|
||||
|
||||
// Attributes
|
||||
attribute := "enableDnsSupport"
|
||||
DescribeAttrOpts := &ec2.DescribeVPCAttributeRequest{
|
||||
DescribeAttrOpts := &ec2.DescribeVPCAttributeInput{
|
||||
Attribute: aws.String(attribute),
|
||||
VPCID: aws.String(vpcid),
|
||||
}
|
||||
resp, err := ec2conn.DescribeVPCAttribute(DescribeAttrOpts)
|
||||
resp, err := conn.DescribeVPCAttribute(DescribeAttrOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.Set("enable_dns_support", *resp.EnableDNSSupport)
|
||||
attribute = "enableDnsHostnames"
|
||||
DescribeAttrOpts = &ec2.DescribeVPCAttributeRequest{
|
||||
DescribeAttrOpts = &ec2.DescribeVPCAttributeInput{
|
||||
Attribute: &attribute,
|
||||
VPCID: &vpcid,
|
||||
}
|
||||
resp, err = ec2conn.DescribeVPCAttribute(DescribeAttrOpts)
|
||||
resp, err = conn.DescribeVPCAttribute(DescribeAttrOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -156,16 +156,16 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
|||
// Really Ugly need to make this better - rmenn
|
||||
filter1 := &ec2.Filter{
|
||||
Name: aws.String("association.main"),
|
||||
Values: []string{("true")},
|
||||
Values: []*string{aws.String("true")},
|
||||
}
|
||||
filter2 := &ec2.Filter{
|
||||
Name: aws.String("vpc-id"),
|
||||
Values: []string{(d.Id())},
|
||||
Values: []*string{aws.String(d.Id())},
|
||||
}
|
||||
DescribeRouteOpts := &ec2.DescribeRouteTablesRequest{
|
||||
Filters: []ec2.Filter{*filter1, *filter2},
|
||||
DescribeRouteOpts := &ec2.DescribeRouteTablesInput{
|
||||
Filters: []*ec2.Filter{filter1, filter2},
|
||||
}
|
||||
routeResp, err := ec2conn.DescribeRouteTables(DescribeRouteOpts)
|
||||
routeResp, err := conn.DescribeRouteTables(DescribeRouteOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -173,21 +173,21 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("main_route_table_id", *v[0].RouteTableID)
|
||||
}
|
||||
|
||||
resourceAwsVpcSetDefaultNetworkAcl(ec2conn, d)
|
||||
resourceAwsVpcSetDefaultSecurityGroup(ec2conn, d)
|
||||
resourceAwsVpcSetDefaultNetworkAcl(conn, d)
|
||||
resourceAwsVpcSetDefaultSecurityGroup(conn, d)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Turn on partial mode
|
||||
d.Partial(true)
|
||||
vpcid := d.Id()
|
||||
if d.HasChange("enable_dns_hostnames") {
|
||||
val := d.Get("enable_dns_hostnames").(bool)
|
||||
modifyOpts := &ec2.ModifyVPCAttributeRequest{
|
||||
modifyOpts := &ec2.ModifyVPCAttributeInput{
|
||||
VPCID: &vpcid,
|
||||
EnableDNSHostnames: &ec2.AttributeBooleanValue{
|
||||
Value: &val,
|
||||
|
@ -197,7 +197,7 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf(
|
||||
"[INFO] Modifying enable_dns_support vpc attribute for %s: %#v",
|
||||
d.Id(), modifyOpts)
|
||||
if err := ec2conn.ModifyVPCAttribute(modifyOpts); err != nil {
|
||||
if _, err := conn.ModifyVPCAttribute(modifyOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
if d.HasChange("enable_dns_support") {
|
||||
val := d.Get("enable_dns_support").(bool)
|
||||
modifyOpts := &ec2.ModifyVPCAttributeRequest{
|
||||
modifyOpts := &ec2.ModifyVPCAttributeInput{
|
||||
VPCID: &vpcid,
|
||||
EnableDNSSupport: &ec2.AttributeBooleanValue{
|
||||
Value: &val,
|
||||
|
@ -216,14 +216,14 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf(
|
||||
"[INFO] Modifying enable_dns_support vpc attribute for %s: %#v",
|
||||
d.Id(), modifyOpts)
|
||||
if err := ec2conn.ModifyVPCAttribute(modifyOpts); err != nil {
|
||||
if _, err := conn.ModifyVPCAttribute(modifyOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetPartial("enable_dns_support")
|
||||
}
|
||||
|
||||
if err := setTags(ec2conn, d); err != nil {
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
|
@ -234,13 +234,13 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
vpcID := d.Id()
|
||||
DeleteVpcOpts := &ec2.DeleteVPCRequest{
|
||||
DeleteVpcOpts := &ec2.DeleteVPCInput{
|
||||
VPCID: &vpcID,
|
||||
}
|
||||
log.Printf("[INFO] Deleting VPC: %s", d.Id())
|
||||
if err := ec2conn.DeleteVPC(DeleteVpcOpts); err != nil {
|
||||
if _, err := conn.DeleteVPC(DeleteVpcOpts); err != nil {
|
||||
ec2err, ok := err.(aws.APIError)
|
||||
if ok && ec2err.Code == "InvalidVpcID.NotFound" {
|
||||
return nil
|
||||
|
@ -256,8 +256,8 @@ func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
// a VPC.
|
||||
func VPCStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
||||
return func() (interface{}, string, error) {
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
||||
VPCIDs: []string{id},
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsInput{
|
||||
VPCIDs: []*string{aws.String(id)},
|
||||
}
|
||||
resp, err := conn.DescribeVPCs(DescribeVpcOpts)
|
||||
if err != nil {
|
||||
|
@ -275,7 +275,7 @@ func VPCStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
|||
return nil, "", nil
|
||||
}
|
||||
|
||||
vpc := &resp.VPCs[0]
|
||||
vpc := resp.VPCs[0]
|
||||
return vpc, *vpc.State, nil
|
||||
}
|
||||
}
|
||||
|
@ -283,14 +283,14 @@ func VPCStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
|||
func resourceAwsVpcSetDefaultNetworkAcl(conn *ec2.EC2, d *schema.ResourceData) error {
|
||||
filter1 := &ec2.Filter{
|
||||
Name: aws.String("default"),
|
||||
Values: []string{("true")},
|
||||
Values: []*string{aws.String("true")},
|
||||
}
|
||||
filter2 := &ec2.Filter{
|
||||
Name: aws.String("vpc-id"),
|
||||
Values: []string{(d.Id())},
|
||||
Values: []*string{aws.String(d.Id())},
|
||||
}
|
||||
DescribeNetworkACLOpts := &ec2.DescribeNetworkACLsRequest{
|
||||
Filters: []ec2.Filter{*filter1, *filter2},
|
||||
DescribeNetworkACLOpts := &ec2.DescribeNetworkACLsInput{
|
||||
Filters: []*ec2.Filter{filter1, filter2},
|
||||
}
|
||||
networkAclResp, err := conn.DescribeNetworkACLs(DescribeNetworkACLOpts)
|
||||
|
||||
|
@ -307,14 +307,14 @@ func resourceAwsVpcSetDefaultNetworkAcl(conn *ec2.EC2, d *schema.ResourceData) e
|
|||
func resourceAwsVpcSetDefaultSecurityGroup(conn *ec2.EC2, d *schema.ResourceData) error {
|
||||
filter1 := &ec2.Filter{
|
||||
Name: aws.String("group-name"),
|
||||
Values: []string{("default")},
|
||||
Values: []*string{aws.String("default")},
|
||||
}
|
||||
filter2 := &ec2.Filter{
|
||||
Name: aws.String("vpc-id"),
|
||||
Values: []string{(d.Id())},
|
||||
Values: []*string{aws.String(d.Id())},
|
||||
}
|
||||
DescribeSgOpts := &ec2.DescribeSecurityGroupsRequest{
|
||||
Filters: []ec2.Filter{*filter1, *filter2},
|
||||
DescribeSgOpts := &ec2.DescribeSecurityGroupsInput{
|
||||
Filters: []*ec2.Filter{filter1, filter2},
|
||||
}
|
||||
securityGroupResp, err := conn.DescribeSecurityGroups(DescribeSgOpts)
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -41,16 +41,16 @@ func resourceAwsVpcPeeringConnection() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Create the vpc peering connection
|
||||
createOpts := &ec2.CreateVPCPeeringConnectionRequest{
|
||||
createOpts := &ec2.CreateVPCPeeringConnectionInput{
|
||||
PeerOwnerID: aws.String(d.Get("peer_owner_id").(string)),
|
||||
PeerVPCID: aws.String(d.Get("peer_vpc_id").(string)),
|
||||
VPCID: aws.String(d.Get("vpc_id").(string)),
|
||||
}
|
||||
log.Printf("[DEBUG] VpcPeeringCreate create config: %#v", createOpts)
|
||||
resp, err := ec2conn.CreateVPCPeeringConnection(createOpts)
|
||||
resp, err := conn.CreateVPCPeeringConnection(createOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating vpc peering connection: %s", err)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending"},
|
||||
Target: "ready",
|
||||
Refresh: resourceAwsVpcPeeringConnectionStateRefreshFunc(ec2conn, d.Id()),
|
||||
Refresh: resourceAwsVpcPeeringConnectionStateRefreshFunc(conn, d.Id()),
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -80,8 +80,8 @@ func resourceAwsVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
pcRaw, _, err := resourceAwsVpcPeeringConnectionStateRefreshFunc(ec2conn, d.Id())()
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
pcRaw, _, err := resourceAwsVpcPeeringConnectionStateRefreshFunc(conn, d.Id())()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -95,15 +95,15 @@ func resourceAwsVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("peer_owner_id", pc.AccepterVPCInfo.OwnerID)
|
||||
d.Set("peer_vpc_id", pc.AccepterVPCInfo.VPCID)
|
||||
d.Set("vpc_id", pc.RequesterVPCInfo.VPCID)
|
||||
d.Set("tags", tagsToMap(pc.Tags))
|
||||
d.Set("tags", tagsToMapSDK(pc.Tags))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsVpcPeeringUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if err := setTags(ec2conn, d); err != nil {
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
|
@ -113,10 +113,10 @@ func resourceAwsVpcPeeringUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpcPeeringDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
_, err := ec2conn.DeleteVPCPeeringConnection(
|
||||
&ec2.DeleteVPCPeeringConnectionRequest{
|
||||
_, err := conn.DeleteVPCPeeringConnection(
|
||||
&ec2.DeleteVPCPeeringConnectionInput{
|
||||
VPCPeeringConnectionID: aws.String(d.Id()),
|
||||
})
|
||||
return err
|
||||
|
@ -127,8 +127,8 @@ func resourceAwsVpcPeeringDelete(d *schema.ResourceData, meta interface{}) error
|
|||
func resourceAwsVpcPeeringConnectionStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
resp, err := conn.DescribeVPCPeeringConnections(&ec2.DescribeVPCPeeringConnectionsRequest{
|
||||
VPCPeeringConnectionIDs: []string{id},
|
||||
resp, err := conn.DescribeVPCPeeringConnections(&ec2.DescribeVPCPeeringConnectionsInput{
|
||||
VPCPeeringConnectionIDs: []*string{aws.String(id)},
|
||||
})
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidVpcPeeringConnectionID.NotFound" {
|
||||
|
@ -145,7 +145,7 @@ func resourceAwsVpcPeeringConnectionStateRefreshFunc(conn *ec2.EC2, id string) r
|
|||
return nil, "", nil
|
||||
}
|
||||
|
||||
pc := &resp.VPCPeeringConnections[0]
|
||||
pc := resp.VPCPeeringConnections[0]
|
||||
|
||||
return pc, "ready", nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -42,8 +43,8 @@ func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
describe, err := conn.DescribeVPCPeeringConnections(
|
||||
&ec2.DescribeVPCPeeringConnectionsRequest{
|
||||
VPCPeeringConnectionIDs: []string{rs.Primary.ID},
|
||||
&ec2.DescribeVPCPeeringConnectionsInput{
|
||||
VPCPeeringConnectionIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -66,7 +66,7 @@ func TestAccVpc_tags(t *testing.T) {
|
|||
testAccCheckVpcCidr(&vpc, "10.1.0.0/16"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_vpc.foo", "cidr_block", "10.1.0.0/16"),
|
||||
testAccCheckTags(&vpc.Tags, "foo", "bar"),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "foo", "bar"),
|
||||
),
|
||||
},
|
||||
|
||||
|
@ -74,8 +74,8 @@ func TestAccVpc_tags(t *testing.T) {
|
|||
Config: testAccVpcConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
testAccCheckTags(&vpc.Tags, "foo", ""),
|
||||
testAccCheckTags(&vpc.Tags, "bar", "baz"),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "foo", ""),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "bar", "baz"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -120,8 +120,8 @@ func testAccCheckVpcDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find the VPC
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
||||
VPCIDs: []string{rs.Primary.ID},
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsInput{
|
||||
VPCIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
resp, err := conn.DescribeVPCs(DescribeVpcOpts)
|
||||
if err == nil {
|
||||
|
@ -168,8 +168,8 @@ func testAccCheckVpcExists(n string, vpc *ec2.VPC) resource.TestCheckFunc {
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
||||
VPCIDs: []string{rs.Primary.ID},
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsInput{
|
||||
VPCIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
}
|
||||
resp, err := conn.DescribeVPCs(DescribeVpcOpts)
|
||||
if err != nil {
|
||||
|
@ -179,7 +179,7 @@ func testAccCheckVpcExists(n string, vpc *ec2.VPC) resource.TestCheckFunc {
|
|||
return fmt.Errorf("VPC not found")
|
||||
}
|
||||
|
||||
*vpc = resp.VPCs[0]
|
||||
*vpc = *resp.VPCs[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -36,16 +36,16 @@ func resourceAwsVpnGateway() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceAwsVpnGatewayCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
createOpts := &ec2.CreateVPNGatewayRequest{
|
||||
createOpts := &ec2.CreateVPNGatewayInput{
|
||||
AvailabilityZone: aws.String(d.Get("availability_zone").(string)),
|
||||
Type: aws.String("ipsec.1"),
|
||||
}
|
||||
|
||||
// Create the VPN gateway
|
||||
log.Printf("[DEBUG] Creating VPN gateway")
|
||||
resp, err := ec2conn.CreateVPNGateway(createOpts)
|
||||
resp, err := conn.CreateVPNGateway(createOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating VPN gateway: %s", err)
|
||||
}
|
||||
|
@ -60,19 +60,28 @@ func resourceAwsVpnGatewayCreate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpnGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
vpnGatewayRaw, _, err := vpnGatewayStateRefreshFunc(ec2conn, d.Id())()
|
||||
resp, err := conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysInput{
|
||||
VPNGatewayIDs: []*string{aws.String(d.Id())},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidVpnGatewayID.NotFound" {
|
||||
d.SetId("")
|
||||
return nil
|
||||
} else {
|
||||
log.Printf("[ERROR] Error finding VpnGateway: %s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
if vpnGatewayRaw == nil {
|
||||
|
||||
vpnGateway := resp.VPNGateways[0]
|
||||
if vpnGateway == nil {
|
||||
// Seems we have lost our VPN gateway
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
|
||||
vpnGateway := vpnGatewayRaw.(*ec2.VPNGateway)
|
||||
if len(vpnGateway.VPCAttachments) == 0 {
|
||||
// Gateway exists but not attached to the VPC
|
||||
d.Set("vpc_id", "")
|
||||
|
@ -80,7 +89,7 @@ func resourceAwsVpnGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("vpc_id", vpnGateway.VPCAttachments[0].VPCID)
|
||||
}
|
||||
d.Set("availability_zone", vpnGateway.AvailabilityZone)
|
||||
d.Set("tags", tagsToMap(vpnGateway.Tags))
|
||||
d.Set("tags", tagsToMapSDK(vpnGateway.Tags))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -98,9 +107,9 @@ func resourceAwsVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
}
|
||||
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if err := setTags(ec2conn, d); err != nil {
|
||||
if err := setTagsSDK(conn, d); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -110,7 +119,7 @@ func resourceAwsVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Detach if it is attached
|
||||
if err := resourceAwsVpnGatewayDetach(d, meta); err != nil {
|
||||
|
@ -120,7 +129,7 @@ func resourceAwsVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error
|
|||
log.Printf("[INFO] Deleting VPN gateway: %s", d.Id())
|
||||
|
||||
return resource.Retry(5*time.Minute, func() error {
|
||||
err := ec2conn.DeleteVPNGateway(&ec2.DeleteVPNGatewayRequest{
|
||||
_, err := conn.DeleteVPNGateway(&ec2.DeleteVPNGatewayInput{
|
||||
VPNGatewayID: aws.String(d.Id()),
|
||||
})
|
||||
if err == nil {
|
||||
|
@ -144,7 +153,7 @@ func resourceAwsVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpnGatewayAttach(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
if d.Get("vpc_id").(string) == "" {
|
||||
log.Printf(
|
||||
|
@ -158,7 +167,7 @@ func resourceAwsVpnGatewayAttach(d *schema.ResourceData, meta interface{}) error
|
|||
d.Id(),
|
||||
d.Get("vpc_id").(string))
|
||||
|
||||
_, err := ec2conn.AttachVPNGateway(&ec2.AttachVPNGatewayRequest{
|
||||
_, err := conn.AttachVPNGateway(&ec2.AttachVPNGatewayInput{
|
||||
VPNGatewayID: aws.String(d.Id()),
|
||||
VPCID: aws.String(d.Get("vpc_id").(string)),
|
||||
})
|
||||
|
@ -176,7 +185,7 @@ func resourceAwsVpnGatewayAttach(d *schema.ResourceData, meta interface{}) error
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"detached", "attaching"},
|
||||
Target: "available",
|
||||
Refresh: VpnGatewayAttachStateRefreshFunc(ec2conn, d.Id(), "available"),
|
||||
Refresh: vpnGatewayAttachStateRefreshFunc(conn, d.Id(), "available"),
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -189,7 +198,7 @@ func resourceAwsVpnGatewayAttach(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceAwsVpnGatewayDetach(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).ec2conn
|
||||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
// Get the old VPC ID to detach from
|
||||
vpcID, _ := d.GetChange("vpc_id")
|
||||
|
@ -207,7 +216,7 @@ func resourceAwsVpnGatewayDetach(d *schema.ResourceData, meta interface{}) error
|
|||
vpcID.(string))
|
||||
|
||||
wait := true
|
||||
err := ec2conn.DetachVPNGateway(&ec2.DetachVPNGatewayRequest{
|
||||
_, err := conn.DetachVPNGateway(&ec2.DetachVPNGatewayInput{
|
||||
VPNGatewayID: aws.String(d.Id()),
|
||||
VPCID: aws.String(d.Get("vpc_id").(string)),
|
||||
})
|
||||
|
@ -237,7 +246,7 @@ func resourceAwsVpnGatewayDetach(d *schema.ResourceData, meta interface{}) error
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"attached", "detaching", "available"},
|
||||
Target: "detached",
|
||||
Refresh: VpnGatewayAttachStateRefreshFunc(ec2conn, d.Id(), "detached"),
|
||||
Refresh: vpnGatewayAttachStateRefreshFunc(conn, d.Id(), "detached"),
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
|
@ -249,43 +258,17 @@ func resourceAwsVpnGatewayDetach(d *schema.ResourceData, meta interface{}) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// vpnGatewayStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch a VPNGateway.
|
||||
func vpnGatewayStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
|
||||
return func() (interface{}, string, error) {
|
||||
resp, err := conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysRequest{
|
||||
VPNGatewayIDs: []string{id},
|
||||
})
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidVpnGatewayID.NotFound" {
|
||||
resp = nil
|
||||
} else {
|
||||
log.Printf("[ERROR] Error on VpnGatewayStateRefresh: %s", err)
|
||||
return nil, "", err
|
||||
}
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
// Sometimes AWS just has consistency issues and doesn't see
|
||||
// our instance yet. Return an empty state.
|
||||
return nil, "", nil
|
||||
}
|
||||
|
||||
vpnGateway := &resp.VPNGateways[0]
|
||||
return vpnGateway, *vpnGateway.State, nil
|
||||
}
|
||||
}
|
||||
|
||||
// VpnGatewayAttachStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// vpnGatewayAttachStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// the state of a VPN gateway's attachment
|
||||
func VpnGatewayAttachStateRefreshFunc(conn *ec2.EC2, id string, expected string) resource.StateRefreshFunc {
|
||||
func vpnGatewayAttachStateRefreshFunc(conn *ec2.EC2, id string, expected string) resource.StateRefreshFunc {
|
||||
var start time.Time
|
||||
return func() (interface{}, string, error) {
|
||||
if start.IsZero() {
|
||||
start = time.Now()
|
||||
}
|
||||
|
||||
resp, err := conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysRequest{
|
||||
VPNGatewayIDs: []string{id},
|
||||
resp, err := conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysInput{
|
||||
VPNGatewayIDs: []*string{aws.String(id)},
|
||||
})
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidVpnGatewayID.NotFound" {
|
||||
|
@ -302,7 +285,7 @@ func VpnGatewayAttachStateRefreshFunc(conn *ec2.EC2, id string, expected string)
|
|||
return nil, "", nil
|
||||
}
|
||||
|
||||
vpnGateway := &resp.VPNGateways[0]
|
||||
vpnGateway := resp.VPNGateways[0]
|
||||
|
||||
if time.Now().Sub(start) > 10*time.Second {
|
||||
return vpnGateway, expected, nil
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSVpnGateway(t *testing.T) {
|
||||
func TestAccAWSVpnGateway_basic(t *testing.T) {
|
||||
var v, v2 ec2.VPNGateway
|
||||
|
||||
testNotEqual := func(*terraform.State) error {
|
||||
|
@ -98,7 +98,7 @@ func TestAccVpnGateway_tags(t *testing.T) {
|
|||
Config: testAccCheckVpnGatewayConfigTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpnGatewayExists("aws_vpn_gateway.foo", &v),
|
||||
testAccCheckTags(&v.Tags, "foo", "bar"),
|
||||
testAccCheckTagsSDK(&v.Tags, "foo", "bar"),
|
||||
),
|
||||
},
|
||||
|
||||
|
@ -106,8 +106,8 @@ func TestAccVpnGateway_tags(t *testing.T) {
|
|||
Config: testAccCheckVpnGatewayConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpnGatewayExists("aws_vpn_gateway.foo", &v),
|
||||
testAccCheckTags(&v.Tags, "foo", ""),
|
||||
testAccCheckTags(&v.Tags, "bar", "baz"),
|
||||
testAccCheckTagsSDK(&v.Tags, "foo", ""),
|
||||
testAccCheckTagsSDK(&v.Tags, "bar", "baz"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -123,8 +123,8 @@ func testAccCheckVpnGatewayDestroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
// Try to find the resource
|
||||
resp, err := ec2conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysRequest{
|
||||
VPNGatewayIDs: []string{rs.Primary.ID},
|
||||
resp, err := ec2conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysInput{
|
||||
VPNGatewayIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err == nil {
|
||||
if len(resp.VPNGateways) > 0 {
|
||||
|
@ -159,8 +159,8 @@ func testAccCheckVpnGatewayExists(n string, ig *ec2.VPNGateway) resource.TestChe
|
|||
}
|
||||
|
||||
ec2conn := testAccProvider.Meta().(*AWSClient).ec2conn
|
||||
resp, err := ec2conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysRequest{
|
||||
VPNGatewayIDs: []string{rs.Primary.ID},
|
||||
resp, err := ec2conn.DescribeVPNGateways(&ec2.DescribeVPNGatewaysInput{
|
||||
VPNGatewayIDs: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -169,7 +169,7 @@ func testAccCheckVpnGatewayExists(n string, ig *ec2.VPNGateway) resource.TestChe
|
|||
return fmt.Errorf("VPNGateway not found")
|
||||
}
|
||||
|
||||
*ig = resp.VPNGateways[0]
|
||||
*ig = *resp.VPNGateways[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/s3"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -23,7 +20,7 @@ func setTagsS3(conn *s3.S3, d *schema.ResourceData) error {
|
|||
// Set tags
|
||||
if len(remove) > 0 {
|
||||
log.Printf("[DEBUG] Removing tags: %#v", remove)
|
||||
err := conn.DeleteBucketTagging(&s3.DeleteBucketTaggingRequest{
|
||||
_, err := conn.DeleteBucketTagging(&s3.DeleteBucketTaggingInput{
|
||||
Bucket: aws.String(d.Get("bucket").(string)),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -32,30 +29,14 @@ func setTagsS3(conn *s3.S3, d *schema.ResourceData) error {
|
|||
}
|
||||
if len(create) > 0 {
|
||||
log.Printf("[DEBUG] Creating tags: %#v", create)
|
||||
tagging := s3.Tagging{
|
||||
TagSet: create,
|
||||
XMLName: xml.Name{
|
||||
Space: "http://s3.amazonaws.com/doc/2006-03-01/",
|
||||
Local: "Tagging",
|
||||
req := &s3.PutBucketTaggingInput{
|
||||
Bucket: aws.String(d.Get("bucket").(string)),
|
||||
Tagging: &s3.Tagging{
|
||||
TagSet: create,
|
||||
},
|
||||
}
|
||||
// AWS S3 API requires us to send a base64 encoded md5 hash of the
|
||||
// content, which we need to build ourselves since aws-sdk-go does not.
|
||||
b, err := xml.Marshal(tagging)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h := md5.New()
|
||||
h.Write(b)
|
||||
base := base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||
|
||||
req := &s3.PutBucketTaggingRequest{
|
||||
Bucket: aws.String(d.Get("bucket").(string)),
|
||||
ContentMD5: aws.String(base),
|
||||
Tagging: &tagging,
|
||||
}
|
||||
|
||||
err = conn.PutBucketTagging(req)
|
||||
_, err := conn.PutBucketTagging(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -68,7 +49,7 @@ func setTagsS3(conn *s3.S3, d *schema.ResourceData) error {
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTagsS3(oldTags, newTags []s3.Tag) ([]s3.Tag, []s3.Tag) {
|
||||
func diffTagsS3(oldTags, newTags []*s3.Tag) ([]*s3.Tag, []*s3.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -76,7 +57,7 @@ func diffTagsS3(oldTags, newTags []s3.Tag) ([]s3.Tag, []s3.Tag) {
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []s3.Tag
|
||||
var remove []*s3.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
|
@ -89,10 +70,10 @@ func diffTagsS3(oldTags, newTags []s3.Tag) ([]s3.Tag, []s3.Tag) {
|
|||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMapS3(m map[string]interface{}) []s3.Tag {
|
||||
result := make([]s3.Tag, 0, len(m))
|
||||
func tagsFromMapS3(m map[string]interface{}) []*s3.Tag {
|
||||
result := make([]*s3.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, s3.Tag{
|
||||
result = append(result, &s3.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
|
@ -102,7 +83,7 @@ func tagsFromMapS3(m map[string]interface{}) []s3.Tag {
|
|||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMapS3(ts []s3.Tag) map[string]string {
|
||||
func tagsToMapS3(ts []*s3.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
|
@ -114,15 +95,15 @@ func tagsToMapS3(ts []s3.Tag) map[string]string {
|
|||
// return a slice of s3 tags associated with the given s3 bucket. Essentially
|
||||
// s3.GetBucketTagging, except returns an empty slice instead of an error when
|
||||
// there are no tags.
|
||||
func getTagSetS3(s3conn *s3.S3, bucket string) ([]s3.Tag, error) {
|
||||
request := &s3.GetBucketTaggingRequest{
|
||||
func getTagSetS3(s3conn *s3.S3, bucket string) ([]*s3.Tag, error) {
|
||||
request := &s3.GetBucketTaggingInput{
|
||||
Bucket: aws.String(bucket),
|
||||
}
|
||||
|
||||
response, err := s3conn.GetBucketTagging(request)
|
||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "NoSuchTagSet" {
|
||||
// There is no tag set associated with the bucket.
|
||||
return []s3.Tag{}, nil
|
||||
return []*s3.Tag{}, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/s3"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ func TestDiffTagsS3(t *testing.T) {
|
|||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckTagsS3(
|
||||
ts *[]s3.Tag, key string, value string) resource.TestCheckFunc {
|
||||
ts *[]*s3.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMapS3(*ts)
|
||||
v, ok := m[key]
|
||||
|
|
|
@ -4,28 +4,30 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
// Takes the result of flatmap.Expand for an array of listeners and
|
||||
// returns ELB API compatible objects
|
||||
func expandListeners(configured []interface{}) ([]elb.Listener, error) {
|
||||
listeners := make([]elb.Listener, 0, len(configured))
|
||||
func expandListeners(configured []interface{}) ([]*elb.Listener, error) {
|
||||
listeners := make([]*elb.Listener, 0, len(configured))
|
||||
|
||||
// Loop over our configured listeners and create
|
||||
// an array of aws-sdk-go compatabile objects
|
||||
for _, lRaw := range configured {
|
||||
data := lRaw.(map[string]interface{})
|
||||
|
||||
l := elb.Listener{
|
||||
InstancePort: aws.Integer(data["instance_port"].(int)),
|
||||
ip := int64(data["instance_port"].(int))
|
||||
lp := int64(data["lb_port"].(int))
|
||||
l := &elb.Listener{
|
||||
InstancePort: &ip,
|
||||
InstanceProtocol: aws.String(data["instance_protocol"].(string)),
|
||||
LoadBalancerPort: aws.Integer(data["lb_port"].(int)),
|
||||
LoadBalancerPort: &lp,
|
||||
Protocol: aws.String(data["lb_protocol"].(string)),
|
||||
}
|
||||
|
||||
|
@ -42,16 +44,16 @@ func expandListeners(configured []interface{}) ([]elb.Listener, error) {
|
|||
// Takes the result of flatmap.Expand for an array of ingress/egress
|
||||
// security group rules and returns EC2 API compatible objects
|
||||
func expandIPPerms(
|
||||
group ec2.SecurityGroup, configured []interface{}) []ec2.IPPermission {
|
||||
group *ec2.SecurityGroup, configured []interface{}) []*ec2.IPPermission {
|
||||
vpc := group.VPCID != nil
|
||||
|
||||
perms := make([]ec2.IPPermission, len(configured))
|
||||
perms := make([]*ec2.IPPermission, len(configured))
|
||||
for i, mRaw := range configured {
|
||||
var perm ec2.IPPermission
|
||||
m := mRaw.(map[string]interface{})
|
||||
|
||||
perm.FromPort = aws.Integer(m["from_port"].(int))
|
||||
perm.ToPort = aws.Integer(m["to_port"].(int))
|
||||
perm.FromPort = aws.Long(int64(m["from_port"].(int)))
|
||||
perm.ToPort = aws.Long(int64(m["to_port"].(int)))
|
||||
perm.IPProtocol = aws.String(m["protocol"].(string))
|
||||
|
||||
var groups []string
|
||||
|
@ -70,14 +72,14 @@ func expandIPPerms(
|
|||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
perm.UserIDGroupPairs = make([]ec2.UserIDGroupPair, len(groups))
|
||||
perm.UserIDGroupPairs = make([]*ec2.UserIDGroupPair, len(groups))
|
||||
for i, name := range groups {
|
||||
ownerId, id := "", name
|
||||
if items := strings.Split(id, "/"); len(items) > 1 {
|
||||
ownerId, id = items[0], items[1]
|
||||
}
|
||||
|
||||
perm.UserIDGroupPairs[i] = ec2.UserIDGroupPair{
|
||||
perm.UserIDGroupPairs[i] = &ec2.UserIDGroupPair{
|
||||
GroupID: aws.String(id),
|
||||
UserID: aws.String(ownerId),
|
||||
}
|
||||
|
@ -91,13 +93,13 @@ func expandIPPerms(
|
|||
|
||||
if raw, ok := m["cidr_blocks"]; ok {
|
||||
list := raw.([]interface{})
|
||||
perm.IPRanges = make([]ec2.IPRange, len(list))
|
||||
perm.IPRanges = make([]*ec2.IPRange, len(list))
|
||||
for i, v := range list {
|
||||
perm.IPRanges[i] = ec2.IPRange{aws.String(v.(string))}
|
||||
perm.IPRanges[i] = &ec2.IPRange{CIDRIP: aws.String(v.(string))}
|
||||
}
|
||||
}
|
||||
|
||||
perms[i] = perm
|
||||
perms[i] = &perm
|
||||
}
|
||||
|
||||
return perms
|
||||
|
@ -105,15 +107,15 @@ func expandIPPerms(
|
|||
|
||||
// Takes the result of flatmap.Expand for an array of parameters and
|
||||
// returns Parameter API compatible objects
|
||||
func expandParameters(configured []interface{}) ([]rds.Parameter, error) {
|
||||
parameters := make([]rds.Parameter, 0, len(configured))
|
||||
func expandParameters(configured []interface{}) ([]*rds.Parameter, error) {
|
||||
parameters := make([]*rds.Parameter, 0, len(configured))
|
||||
|
||||
// Loop over our configured parameters and create
|
||||
// an array of aws-sdk-go compatabile objects
|
||||
for _, pRaw := range configured {
|
||||
data := pRaw.(map[string]interface{})
|
||||
|
||||
p := rds.Parameter{
|
||||
p := &rds.Parameter{
|
||||
ApplyMethod: aws.String(data["apply_method"].(string)),
|
||||
ParameterName: aws.String(data["name"].(string)),
|
||||
ParameterValue: aws.String(data["value"].(string)),
|
||||
|
@ -143,7 +145,7 @@ func flattenHealthCheck(check *elb.HealthCheck) []map[string]interface{} {
|
|||
}
|
||||
|
||||
// Flattens an array of UserSecurityGroups into a []string
|
||||
func flattenSecurityGroups(list []ec2.UserIDGroupPair) []string {
|
||||
func flattenSecurityGroups(list []*ec2.UserIDGroupPair) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
for _, g := range list {
|
||||
result = append(result, *g.GroupID)
|
||||
|
@ -152,7 +154,7 @@ func flattenSecurityGroups(list []ec2.UserIDGroupPair) []string {
|
|||
}
|
||||
|
||||
// Flattens an array of Instances into a []string
|
||||
func flattenInstances(list []elb.Instance) []string {
|
||||
func flattenInstances(list []*elb.Instance) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, *i.InstanceID)
|
||||
|
@ -161,16 +163,16 @@ func flattenInstances(list []elb.Instance) []string {
|
|||
}
|
||||
|
||||
// Expands an array of String Instance IDs into a []Instances
|
||||
func expandInstanceString(list []interface{}) []elb.Instance {
|
||||
result := make([]elb.Instance, 0, len(list))
|
||||
func expandInstanceString(list []interface{}) []*elb.Instance {
|
||||
result := make([]*elb.Instance, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, elb.Instance{aws.String(i.(string))})
|
||||
result = append(result, &elb.Instance{InstanceID: aws.String(i.(string))})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of Listeners into a []map[string]interface{}
|
||||
func flattenListeners(list []elb.ListenerDescription) []map[string]interface{} {
|
||||
func flattenListeners(list []*elb.ListenerDescription) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, len(list))
|
||||
for _, i := range list {
|
||||
l := map[string]interface{}{
|
||||
|
@ -189,7 +191,7 @@ func flattenListeners(list []elb.ListenerDescription) []map[string]interface{} {
|
|||
}
|
||||
|
||||
// Flattens an array of Parameters into a []map[string]interface{}
|
||||
func flattenParameters(list []rds.Parameter) []map[string]interface{} {
|
||||
func flattenParameters(list []*rds.Parameter) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, map[string]interface{}{
|
||||
|
@ -202,16 +204,16 @@ func flattenParameters(list []rds.Parameter) []map[string]interface{} {
|
|||
|
||||
// Takes the result of flatmap.Expand for an array of strings
|
||||
// and returns a []string
|
||||
func expandStringList(configured []interface{}) []string {
|
||||
vs := make([]string, 0, len(configured))
|
||||
func expandStringList(configured []interface{}) []*string {
|
||||
vs := make([]*string, 0, len(configured))
|
||||
for _, v := range configured {
|
||||
vs = append(vs, v.(string))
|
||||
vs = append(vs, aws.String(v.(string)))
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
||||
//Flattens an array of private ip addresses into a []string, where the elements returned are the IP strings e.g. "192.168.0.0"
|
||||
func flattenNetworkInterfacesPrivateIPAddesses(dtos []ec2.NetworkInterfacePrivateIPAddress) []string {
|
||||
func flattenNetworkInterfacesPrivateIPAddesses(dtos []*ec2.NetworkInterfacePrivateIPAddress) []string {
|
||||
ips := make([]string, 0, len(dtos))
|
||||
for _, v := range dtos {
|
||||
ip := *v.PrivateIPAddress
|
||||
|
@ -221,7 +223,7 @@ func flattenNetworkInterfacesPrivateIPAddesses(dtos []ec2.NetworkInterfacePrivat
|
|||
}
|
||||
|
||||
//Flattens security group identifiers into a []string, where the elements returned are the GroupIDs
|
||||
func flattenGroupIdentifiers(dtos []ec2.GroupIdentifier) []string {
|
||||
func flattenGroupIdentifiers(dtos []*ec2.GroupIdentifier) []string {
|
||||
ids := make([]string, 0, len(dtos))
|
||||
for _, v := range dtos {
|
||||
group_id := *v.GroupID
|
||||
|
@ -231,10 +233,10 @@ func flattenGroupIdentifiers(dtos []ec2.GroupIdentifier) []string {
|
|||
}
|
||||
|
||||
//Expands an array of IPs into a ec2 Private IP Address Spec
|
||||
func expandPrivateIPAddesses(ips []interface{}) []ec2.PrivateIPAddressSpecification {
|
||||
dtos := make([]ec2.PrivateIPAddressSpecification, 0, len(ips))
|
||||
func expandPrivateIPAddesses(ips []interface{}) []*ec2.PrivateIPAddressSpecification {
|
||||
dtos := make([]*ec2.PrivateIPAddressSpecification, 0, len(ips))
|
||||
for i, v := range ips {
|
||||
new_private_ip := ec2.PrivateIPAddressSpecification{
|
||||
new_private_ip := &ec2.PrivateIPAddressSpecification{
|
||||
PrivateIPAddress: aws.String(v.(string)),
|
||||
}
|
||||
|
||||
|
@ -254,7 +256,7 @@ func flattenAttachment(a *ec2.NetworkInterfaceAttachment) map[string]interface{}
|
|||
return att
|
||||
}
|
||||
|
||||
func flattenResourceRecords(recs []route53.ResourceRecord) []string {
|
||||
func flattenResourceRecords(recs []*route53.ResourceRecord) []string {
|
||||
strs := make([]string, 0, len(recs))
|
||||
for _, r := range recs {
|
||||
if r.Value != nil {
|
||||
|
@ -265,16 +267,16 @@ func flattenResourceRecords(recs []route53.ResourceRecord) []string {
|
|||
return strs
|
||||
}
|
||||
|
||||
func expandResourceRecords(recs []interface{}, typeStr string) []route53.ResourceRecord {
|
||||
records := make([]route53.ResourceRecord, 0, len(recs))
|
||||
func expandResourceRecords(recs []interface{}, typeStr string) []*route53.ResourceRecord {
|
||||
records := make([]*route53.ResourceRecord, 0, len(recs))
|
||||
for _, r := range recs {
|
||||
s := r.(string)
|
||||
switch typeStr {
|
||||
case "TXT":
|
||||
str := fmt.Sprintf("\"%s\"", s)
|
||||
records = append(records, route53.ResourceRecord{Value: aws.String(str)})
|
||||
records = append(records, &route53.ResourceRecord{Value: aws.String(str)})
|
||||
default:
|
||||
records = append(records, route53.ResourceRecord{Value: aws.String(s)})
|
||||
records = append(records, &route53.ResourceRecord{Value: aws.String(s)})
|
||||
}
|
||||
}
|
||||
return records
|
||||
|
|
|
@ -1,255 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
// Takes the result of flatmap.Expand for an array of listeners and
|
||||
// returns ELB API compatible objects
|
||||
func expandListenersSDK(configured []interface{}) ([]elb.Listener, error) {
|
||||
listeners := make([]elb.Listener, 0, len(configured))
|
||||
|
||||
// Loop over our configured listeners and create
|
||||
// an array of aws-sdk-go compatabile objects
|
||||
for _, lRaw := range configured {
|
||||
data := lRaw.(map[string]interface{})
|
||||
|
||||
ip := data["instance_port"].(int)
|
||||
lp := data["lb_port"].(int)
|
||||
l := elb.Listener{
|
||||
InstancePort: &ip,
|
||||
InstanceProtocol: aws.String(data["instance_protocol"].(string)),
|
||||
LoadBalancerPort: &lp,
|
||||
Protocol: aws.String(data["lb_protocol"].(string)),
|
||||
}
|
||||
|
||||
if v, ok := data["ssl_certificate_id"]; ok {
|
||||
l.SSLCertificateID = aws.String(v.(string))
|
||||
}
|
||||
|
||||
listeners = append(listeners, l)
|
||||
}
|
||||
|
||||
return listeners, nil
|
||||
}
|
||||
|
||||
// Takes the result of flatmap.Expand for an array of ingress/egress
|
||||
// security group rules and returns EC2 API compatible objects
|
||||
func expandIPPermsSDK(
|
||||
group *ec2.SecurityGroup, configured []interface{}) []*ec2.IPPermission {
|
||||
vpc := group.VPCID != nil
|
||||
|
||||
perms := make([]*ec2.IPPermission, len(configured))
|
||||
for i, mRaw := range configured {
|
||||
var perm ec2.IPPermission
|
||||
m := mRaw.(map[string]interface{})
|
||||
|
||||
perm.FromPort = aws.Long(int64(m["from_port"].(int)))
|
||||
perm.ToPort = aws.Long(int64(m["to_port"].(int)))
|
||||
perm.IPProtocol = aws.String(m["protocol"].(string))
|
||||
|
||||
var groups []string
|
||||
if raw, ok := m["security_groups"]; ok {
|
||||
list := raw.(*schema.Set).List()
|
||||
for _, v := range list {
|
||||
groups = append(groups, v.(string))
|
||||
}
|
||||
}
|
||||
if v, ok := m["self"]; ok && v.(bool) {
|
||||
if vpc {
|
||||
groups = append(groups, *group.GroupID)
|
||||
} else {
|
||||
groups = append(groups, *group.GroupName)
|
||||
}
|
||||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
perm.UserIDGroupPairs = make([]*ec2.UserIDGroupPair, len(groups))
|
||||
for i, name := range groups {
|
||||
ownerId, id := "", name
|
||||
if items := strings.Split(id, "/"); len(items) > 1 {
|
||||
ownerId, id = items[0], items[1]
|
||||
}
|
||||
|
||||
perm.UserIDGroupPairs[i] = &ec2.UserIDGroupPair{
|
||||
GroupID: aws.String(id),
|
||||
UserID: aws.String(ownerId),
|
||||
}
|
||||
if !vpc {
|
||||
perm.UserIDGroupPairs[i].GroupID = nil
|
||||
perm.UserIDGroupPairs[i].GroupName = aws.String(id)
|
||||
perm.UserIDGroupPairs[i].UserID = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if raw, ok := m["cidr_blocks"]; ok {
|
||||
list := raw.([]interface{})
|
||||
perm.IPRanges = make([]*ec2.IPRange, len(list))
|
||||
for i, v := range list {
|
||||
perm.IPRanges[i] = &ec2.IPRange{CIDRIP: aws.String(v.(string))}
|
||||
}
|
||||
}
|
||||
|
||||
perms[i] = &perm
|
||||
}
|
||||
|
||||
return perms
|
||||
}
|
||||
|
||||
// Takes the result of flatmap.Expand for an array of parameters and
|
||||
// returns Parameter API compatible objects
|
||||
func expandParametersSDK(configured []interface{}) ([]rds.Parameter, error) {
|
||||
parameters := make([]rds.Parameter, 0, len(configured))
|
||||
|
||||
// Loop over our configured parameters and create
|
||||
// an array of aws-sdk-go compatabile objects
|
||||
for _, pRaw := range configured {
|
||||
data := pRaw.(map[string]interface{})
|
||||
|
||||
p := rds.Parameter{
|
||||
ApplyMethod: aws.String(data["apply_method"].(string)),
|
||||
ParameterName: aws.String(data["name"].(string)),
|
||||
ParameterValue: aws.String(data["value"].(string)),
|
||||
}
|
||||
|
||||
parameters = append(parameters, p)
|
||||
}
|
||||
|
||||
return parameters, nil
|
||||
}
|
||||
|
||||
// Flattens a health check into something that flatmap.Flatten()
|
||||
// can handle
|
||||
func flattenHealthCheckSDK(check *elb.HealthCheck) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, 1)
|
||||
|
||||
chk := make(map[string]interface{})
|
||||
chk["unhealthy_threshold"] = *check.UnhealthyThreshold
|
||||
chk["healthy_threshold"] = *check.HealthyThreshold
|
||||
chk["target"] = *check.Target
|
||||
chk["timeout"] = *check.Timeout
|
||||
chk["interval"] = *check.Interval
|
||||
|
||||
result = append(result, chk)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of UserSecurityGroups into a []string
|
||||
func flattenSecurityGroupsSDK(list []*ec2.UserIDGroupPair) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
for _, g := range list {
|
||||
result = append(result, *g.GroupID)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of Instances into a []string
|
||||
func flattenInstancesSDK(list []elb.Instance) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, *i.InstanceID)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Expands an array of String Instance IDs into a []Instances
|
||||
func expandInstanceStringSDK(list []interface{}) []elb.Instance {
|
||||
result := make([]elb.Instance, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, elb.Instance{aws.String(i.(string))})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of Listeners into a []map[string]interface{}
|
||||
func flattenListenersSDK(list []elb.ListenerDescription) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, len(list))
|
||||
for _, i := range list {
|
||||
l := map[string]interface{}{
|
||||
"instance_port": *i.Listener.InstancePort,
|
||||
"instance_protocol": strings.ToLower(*i.Listener.InstanceProtocol),
|
||||
"lb_port": *i.Listener.LoadBalancerPort,
|
||||
"lb_protocol": strings.ToLower(*i.Listener.Protocol),
|
||||
}
|
||||
// SSLCertificateID is optional, and may be nil
|
||||
if i.Listener.SSLCertificateID != nil {
|
||||
l["ssl_certificate_id"] = *i.Listener.SSLCertificateID
|
||||
}
|
||||
result = append(result, l)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Flattens an array of Parameters into a []map[string]interface{}
|
||||
func flattenParametersSDK(list []rds.Parameter) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, len(list))
|
||||
for _, i := range list {
|
||||
result = append(result, map[string]interface{}{
|
||||
"name": strings.ToLower(*i.ParameterName),
|
||||
"value": strings.ToLower(*i.ParameterValue),
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Takes the result of flatmap.Expand for an array of strings
|
||||
// and returns a []string
|
||||
func expandStringListSDK(configured []interface{}) []*string {
|
||||
vs := make([]*string, 0, len(configured))
|
||||
for _, v := range configured {
|
||||
vs = append(vs, aws.String(v.(string)))
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
||||
//Flattens an array of private ip addresses into a []string, where the elements returned are the IP strings e.g. "192.168.0.0"
|
||||
func flattenNetworkInterfacesPrivateIPAddessesSDK(dtos []*ec2.NetworkInterfacePrivateIPAddress) []string {
|
||||
ips := make([]string, 0, len(dtos))
|
||||
for _, v := range dtos {
|
||||
ip := *v.PrivateIPAddress
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
return ips
|
||||
}
|
||||
|
||||
//Flattens security group identifiers into a []string, where the elements returned are the GroupIDs
|
||||
func flattenGroupIdentifiersSDK(dtos []*ec2.GroupIdentifier) []string {
|
||||
ids := make([]string, 0, len(dtos))
|
||||
for _, v := range dtos {
|
||||
group_id := *v.GroupID
|
||||
ids = append(ids, group_id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
//Expands an array of IPs into a ec2 Private IP Address Spec
|
||||
func expandPrivateIPAddessesSDK(ips []interface{}) []*ec2.PrivateIPAddressSpecification {
|
||||
dtos := make([]*ec2.PrivateIPAddressSpecification, 0, len(ips))
|
||||
for i, v := range ips {
|
||||
new_private_ip := &ec2.PrivateIPAddressSpecification{
|
||||
PrivateIPAddress: aws.String(v.(string)),
|
||||
}
|
||||
|
||||
new_private_ip.Primary = aws.Boolean(i == 0)
|
||||
|
||||
dtos = append(dtos, new_private_ip)
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
//Flattens network interface attachment into a map[string]interface
|
||||
func flattenAttachmentSDK(a *ec2.NetworkInterfaceAttachment) map[string]interface{} {
|
||||
att := make(map[string]interface{})
|
||||
att["instance"] = *a.InstanceID
|
||||
att["device_index"] = *a.DeviceIndex
|
||||
att["attachment_id"] = *a.AttachmentID
|
||||
return att
|
||||
}
|
|
@ -1,444 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
// Returns test configuration
|
||||
func testConfSDK() map[string]string {
|
||||
return map[string]string{
|
||||
"listener.#": "1",
|
||||
"listener.0.lb_port": "80",
|
||||
"listener.0.lb_protocol": "http",
|
||||
"listener.0.instance_port": "8000",
|
||||
"listener.0.instance_protocol": "http",
|
||||
"availability_zones.#": "2",
|
||||
"availability_zones.0": "us-east-1a",
|
||||
"availability_zones.1": "us-east-1b",
|
||||
"ingress.#": "1",
|
||||
"ingress.0.protocol": "icmp",
|
||||
"ingress.0.from_port": "1",
|
||||
"ingress.0.to_port": "-1",
|
||||
"ingress.0.cidr_blocks.#": "1",
|
||||
"ingress.0.cidr_blocks.0": "0.0.0.0/0",
|
||||
"ingress.0.security_groups.#": "2",
|
||||
"ingress.0.security_groups.0": "sg-11111",
|
||||
"ingress.0.security_groups.1": "foo/sg-22222",
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandIPPermsSDK(t *testing.T) {
|
||||
hash := func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"protocol": "icmp",
|
||||
"from_port": 1,
|
||||
"to_port": -1,
|
||||
"cidr_blocks": []interface{}{"0.0.0.0/0"},
|
||||
"security_groups": schema.NewSet(hash, []interface{}{
|
||||
"sg-11111",
|
||||
"foo/sg-22222",
|
||||
}),
|
||||
},
|
||||
map[string]interface{}{
|
||||
"protocol": "icmp",
|
||||
"from_port": 1,
|
||||
"to_port": -1,
|
||||
"self": true,
|
||||
},
|
||||
}
|
||||
group := &ec2.SecurityGroup{
|
||||
GroupID: aws.String("foo"),
|
||||
VPCID: aws.String("bar"),
|
||||
}
|
||||
perms := expandIPPermsSDK(group, expanded)
|
||||
|
||||
expected := []ec2.IPPermission{
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Long(1),
|
||||
ToPort: aws.Long(-1),
|
||||
IPRanges: []*ec2.IPRange{&ec2.IPRange{CIDRIP: aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
UserID: aws.String("foo"),
|
||||
GroupID: aws.String("sg-22222"),
|
||||
},
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupID: aws.String("sg-22222"),
|
||||
},
|
||||
},
|
||||
},
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Long(1),
|
||||
ToPort: aws.Long(-1),
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
UserID: aws.String("foo"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
exp := expected[0]
|
||||
perm := perms[0]
|
||||
|
||||
if *exp.FromPort != *perm.FromPort {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
*perm.FromPort,
|
||||
*exp.FromPort)
|
||||
}
|
||||
|
||||
if *exp.IPRanges[0].CIDRIP != *perm.IPRanges[0].CIDRIP {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
*perm.IPRanges[0].CIDRIP,
|
||||
*exp.IPRanges[0].CIDRIP)
|
||||
}
|
||||
|
||||
if *exp.UserIDGroupPairs[0].UserID != *perm.UserIDGroupPairs[0].UserID {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
*perm.UserIDGroupPairs[0].UserID,
|
||||
*exp.UserIDGroupPairs[0].UserID)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestExpandIPPerms_nonVPCSDK(t *testing.T) {
|
||||
hash := func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"protocol": "icmp",
|
||||
"from_port": 1,
|
||||
"to_port": -1,
|
||||
"cidr_blocks": []interface{}{"0.0.0.0/0"},
|
||||
"security_groups": schema.NewSet(hash, []interface{}{
|
||||
"sg-11111",
|
||||
"foo/sg-22222",
|
||||
}),
|
||||
},
|
||||
map[string]interface{}{
|
||||
"protocol": "icmp",
|
||||
"from_port": 1,
|
||||
"to_port": -1,
|
||||
"self": true,
|
||||
},
|
||||
}
|
||||
group := &ec2.SecurityGroup{
|
||||
GroupName: aws.String("foo"),
|
||||
}
|
||||
perms := expandIPPermsSDK(group, expanded)
|
||||
|
||||
expected := []ec2.IPPermission{
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Long(1),
|
||||
ToPort: aws.Long(-1),
|
||||
IPRanges: []*ec2.IPRange{&ec2.IPRange{CIDRIP: aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("sg-22222"),
|
||||
},
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("sg-22222"),
|
||||
},
|
||||
},
|
||||
},
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Long(1),
|
||||
ToPort: aws.Long(-1),
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("foo"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
exp := expected[0]
|
||||
perm := perms[0]
|
||||
|
||||
if *exp.FromPort != *perm.FromPort {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
*perm.FromPort,
|
||||
*exp.FromPort)
|
||||
}
|
||||
|
||||
if *exp.IPRanges[0].CIDRIP != *perm.IPRanges[0].CIDRIP {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
*perm.IPRanges[0].CIDRIP,
|
||||
*exp.IPRanges[0].CIDRIP)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandListenersSDK(t *testing.T) {
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"instance_port": 8000,
|
||||
"lb_port": 80,
|
||||
"instance_protocol": "http",
|
||||
"lb_protocol": "http",
|
||||
},
|
||||
}
|
||||
listeners, err := expandListenersSDK(expanded)
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
|
||||
expected := elb.Listener{
|
||||
InstancePort: aws.Integer(8000),
|
||||
LoadBalancerPort: aws.Integer(80),
|
||||
InstanceProtocol: aws.String("http"),
|
||||
Protocol: aws.String("http"),
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(listeners[0], expected) {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
listeners[0],
|
||||
expected)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestFlattenHealthCheckSDK(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input elb.HealthCheck
|
||||
Output []map[string]interface{}
|
||||
}{
|
||||
{
|
||||
Input: elb.HealthCheck{
|
||||
UnhealthyThreshold: aws.Integer(10),
|
||||
HealthyThreshold: aws.Integer(10),
|
||||
Target: aws.String("HTTP:80/"),
|
||||
Timeout: aws.Integer(30),
|
||||
Interval: aws.Integer(30),
|
||||
},
|
||||
Output: []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"unhealthy_threshold": 10,
|
||||
"healthy_threshold": 10,
|
||||
"target": "HTTP:80/",
|
||||
"timeout": 30,
|
||||
"interval": 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
output := flattenHealthCheckSDK(&tc.Input)
|
||||
if !reflect.DeepEqual(output, tc.Output) {
|
||||
t.Fatalf("Got:\n\n%#v\n\nExpected:\n\n%#v", output, tc.Output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandStringListSDK(t *testing.T) {
|
||||
expanded := flatmap.Expand(testConfSDK(), "availability_zones").([]interface{})
|
||||
stringList := expandStringList(expanded)
|
||||
expected := []string{
|
||||
"us-east-1a",
|
||||
"us-east-1b",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(stringList, expected) {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
stringList,
|
||||
expected)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestExpandParametersSDK(t *testing.T) {
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"name": "character_set_client",
|
||||
"value": "utf8",
|
||||
"apply_method": "immediate",
|
||||
},
|
||||
}
|
||||
parameters, err := expandParametersSDK(expanded)
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
|
||||
expected := rds.Parameter{
|
||||
ParameterName: aws.String("character_set_client"),
|
||||
ParameterValue: aws.String("utf8"),
|
||||
ApplyMethod: aws.String("immediate"),
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(parameters[0], expected) {
|
||||
t.Fatalf(
|
||||
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
|
||||
parameters[0],
|
||||
expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenParametersSDK(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input []rds.Parameter
|
||||
Output []map[string]interface{}
|
||||
}{
|
||||
{
|
||||
Input: []rds.Parameter{
|
||||
rds.Parameter{
|
||||
ParameterName: aws.String("character_set_client"),
|
||||
ParameterValue: aws.String("utf8"),
|
||||
},
|
||||
},
|
||||
Output: []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"name": "character_set_client",
|
||||
"value": "utf8",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
output := flattenParametersSDK(tc.Input)
|
||||
if !reflect.DeepEqual(output, tc.Output) {
|
||||
t.Fatalf("Got:\n\n%#v\n\nExpected:\n\n%#v", output, tc.Output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandInstanceStringSDK(t *testing.T) {
|
||||
|
||||
expected := []elb.Instance{
|
||||
elb.Instance{aws.String("test-one")},
|
||||
elb.Instance{aws.String("test-two")},
|
||||
}
|
||||
|
||||
ids := []interface{}{
|
||||
"test-one",
|
||||
"test-two",
|
||||
}
|
||||
|
||||
expanded := expandInstanceStringSDK(ids)
|
||||
|
||||
if !reflect.DeepEqual(expanded, expected) {
|
||||
t.Fatalf("Expand Instance String output did not match.\nGot:\n%#v\n\nexpected:\n%#v", expanded, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenNetworkInterfacesPrivateIPAddessesSDK(t *testing.T) {
|
||||
expanded := []*ec2.NetworkInterfacePrivateIPAddress{
|
||||
&ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.1")},
|
||||
&ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.2")},
|
||||
}
|
||||
|
||||
result := flattenNetworkInterfacesPrivateIPAddessesSDK(expanded)
|
||||
|
||||
if result == nil {
|
||||
t.Fatal("result was nil")
|
||||
}
|
||||
|
||||
if len(result) != 2 {
|
||||
t.Fatalf("expected result had %d elements, but got %d", 2, len(result))
|
||||
}
|
||||
|
||||
if result[0] != "192.168.0.1" {
|
||||
t.Fatalf("expected ip to be 192.168.0.1, but was %s", result[0])
|
||||
}
|
||||
|
||||
if result[1] != "192.168.0.2" {
|
||||
t.Fatalf("expected ip to be 192.168.0.2, but was %s", result[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenGroupIdentifiersSDK(t *testing.T) {
|
||||
expanded := []*ec2.GroupIdentifier{
|
||||
&ec2.GroupIdentifier{GroupID: aws.String("sg-001")},
|
||||
&ec2.GroupIdentifier{GroupID: aws.String("sg-002")},
|
||||
}
|
||||
|
||||
result := flattenGroupIdentifiersSDK(expanded)
|
||||
|
||||
if len(result) != 2 {
|
||||
t.Fatalf("expected result had %d elements, but got %d", 2, len(result))
|
||||
}
|
||||
|
||||
if result[0] != "sg-001" {
|
||||
t.Fatalf("expected id to be sg-001, but was %s", result[0])
|
||||
}
|
||||
|
||||
if result[1] != "sg-002" {
|
||||
t.Fatalf("expected id to be sg-002, but was %s", result[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandPrivateIPAddessesSDK(t *testing.T) {
|
||||
|
||||
ip1 := "192.168.0.1"
|
||||
ip2 := "192.168.0.2"
|
||||
flattened := []interface{}{
|
||||
ip1,
|
||||
ip2,
|
||||
}
|
||||
|
||||
result := expandPrivateIPAddessesSDK(flattened)
|
||||
|
||||
if len(result) != 2 {
|
||||
t.Fatalf("expected result had %d elements, but got %d", 2, len(result))
|
||||
}
|
||||
|
||||
if *result[0].PrivateIPAddress != "192.168.0.1" || !*result[0].Primary {
|
||||
t.Fatalf("expected ip to be 192.168.0.1 and Primary, but got %v, %t", *result[0].PrivateIPAddress, *result[0].Primary)
|
||||
}
|
||||
|
||||
if *result[1].PrivateIPAddress != "192.168.0.2" || *result[1].Primary {
|
||||
t.Fatalf("expected ip to be 192.168.0.2 and not Primary, but got %v, %t", *result[1].PrivateIPAddress, *result[1].Primary)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenAttachmentSDK(t *testing.T) {
|
||||
expanded := &ec2.NetworkInterfaceAttachment{
|
||||
InstanceID: aws.String("i-00001"),
|
||||
DeviceIndex: aws.Long(1),
|
||||
AttachmentID: aws.String("at-002"),
|
||||
}
|
||||
|
||||
result := flattenAttachmentSDK(expanded)
|
||||
|
||||
if result == nil {
|
||||
t.Fatal("expected result to have value, but got nil")
|
||||
}
|
||||
|
||||
if result["instance"] != "i-00001" {
|
||||
t.Fatalf("expected instance to be i-00001, but got %s", result["instance"])
|
||||
}
|
||||
|
||||
if result["device_index"] != int64(1) {
|
||||
t.Fatalf("expected device_index to be 1, but got %d", result["device_index"])
|
||||
}
|
||||
|
||||
if result["attachment_id"] != "at-002" {
|
||||
t.Fatalf("expected attachment_id to be at-002, but got %s", result["attachment_id"])
|
||||
}
|
||||
}
|
|
@ -4,11 +4,11 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
ec2 "github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -37,7 +37,7 @@ func testConf() map[string]string {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpandIPPerms(t *testing.T) {
|
||||
func TestexpandIPPerms(t *testing.T) {
|
||||
hash := func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func TestExpandIPPerms(t *testing.T) {
|
|||
"self": true,
|
||||
},
|
||||
}
|
||||
group := ec2.SecurityGroup{
|
||||
group := &ec2.SecurityGroup{
|
||||
GroupID: aws.String("foo"),
|
||||
VPCID: aws.String("bar"),
|
||||
}
|
||||
|
@ -69,25 +69,25 @@ func TestExpandIPPerms(t *testing.T) {
|
|||
expected := []ec2.IPPermission{
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Integer(1),
|
||||
ToPort: aws.Integer(-1),
|
||||
IPRanges: []ec2.IPRange{ec2.IPRange{aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||
ec2.UserIDGroupPair{
|
||||
FromPort: aws.Long(int64(1)),
|
||||
ToPort: aws.Long(int64(-1)),
|
||||
IPRanges: []*ec2.IPRange{&ec2.IPRange{CIDRIP: aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
UserID: aws.String("foo"),
|
||||
GroupID: aws.String("sg-22222"),
|
||||
},
|
||||
ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupID: aws.String("sg-22222"),
|
||||
},
|
||||
},
|
||||
},
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Integer(1),
|
||||
ToPort: aws.Integer(-1),
|
||||
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||
ec2.UserIDGroupPair{
|
||||
FromPort: aws.Long(int64(1)),
|
||||
ToPort: aws.Long(int64(-1)),
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
UserID: aws.String("foo"),
|
||||
},
|
||||
},
|
||||
|
@ -143,7 +143,7 @@ func TestExpandIPPerms_nonVPC(t *testing.T) {
|
|||
"self": true,
|
||||
},
|
||||
}
|
||||
group := ec2.SecurityGroup{
|
||||
group := &ec2.SecurityGroup{
|
||||
GroupName: aws.String("foo"),
|
||||
}
|
||||
perms := expandIPPerms(group, expanded)
|
||||
|
@ -151,24 +151,24 @@ func TestExpandIPPerms_nonVPC(t *testing.T) {
|
|||
expected := []ec2.IPPermission{
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Integer(1),
|
||||
ToPort: aws.Integer(-1),
|
||||
IPRanges: []ec2.IPRange{ec2.IPRange{aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||
ec2.UserIDGroupPair{
|
||||
FromPort: aws.Long(int64(1)),
|
||||
ToPort: aws.Long(int64(-1)),
|
||||
IPRanges: []*ec2.IPRange{&ec2.IPRange{CIDRIP: aws.String("0.0.0.0/0")}},
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("sg-22222"),
|
||||
},
|
||||
ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("sg-22222"),
|
||||
},
|
||||
},
|
||||
},
|
||||
ec2.IPPermission{
|
||||
IPProtocol: aws.String("icmp"),
|
||||
FromPort: aws.Integer(1),
|
||||
ToPort: aws.Integer(-1),
|
||||
UserIDGroupPairs: []ec2.UserIDGroupPair{
|
||||
ec2.UserIDGroupPair{
|
||||
FromPort: aws.Long(int64(1)),
|
||||
ToPort: aws.Long(int64(-1)),
|
||||
UserIDGroupPairs: []*ec2.UserIDGroupPair{
|
||||
&ec2.UserIDGroupPair{
|
||||
GroupName: aws.String("foo"),
|
||||
},
|
||||
},
|
||||
|
@ -193,7 +193,7 @@ func TestExpandIPPerms_nonVPC(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpandListeners(t *testing.T) {
|
||||
func TestexpandListeners(t *testing.T) {
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"instance_port": 8000,
|
||||
|
@ -207,9 +207,9 @@ func TestExpandListeners(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
|
||||
expected := elb.Listener{
|
||||
InstancePort: aws.Integer(8000),
|
||||
LoadBalancerPort: aws.Integer(80),
|
||||
expected := &elb.Listener{
|
||||
InstancePort: aws.Long(int64(8000)),
|
||||
LoadBalancerPort: aws.Long(int64(80)),
|
||||
InstanceProtocol: aws.String("http"),
|
||||
Protocol: aws.String("http"),
|
||||
}
|
||||
|
@ -223,33 +223,33 @@ func TestExpandListeners(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestFlattenHealthCheck(t *testing.T) {
|
||||
func TestflattenHealthCheck(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input elb.HealthCheck
|
||||
Input *elb.HealthCheck
|
||||
Output []map[string]interface{}
|
||||
}{
|
||||
{
|
||||
Input: elb.HealthCheck{
|
||||
UnhealthyThreshold: aws.Integer(10),
|
||||
HealthyThreshold: aws.Integer(10),
|
||||
Input: &elb.HealthCheck{
|
||||
UnhealthyThreshold: aws.Long(int64(10)),
|
||||
HealthyThreshold: aws.Long(int64(10)),
|
||||
Target: aws.String("HTTP:80/"),
|
||||
Timeout: aws.Integer(30),
|
||||
Interval: aws.Integer(30),
|
||||
Timeout: aws.Long(int64(30)),
|
||||
Interval: aws.Long(int64(30)),
|
||||
},
|
||||
Output: []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"unhealthy_threshold": 10,
|
||||
"healthy_threshold": 10,
|
||||
"unhealthy_threshold": int64(10),
|
||||
"healthy_threshold": int64(10),
|
||||
"target": "HTTP:80/",
|
||||
"timeout": 30,
|
||||
"interval": 30,
|
||||
"timeout": int64(30),
|
||||
"interval": int64(30),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
output := flattenHealthCheck(&tc.Input)
|
||||
output := flattenHealthCheck(tc.Input)
|
||||
if !reflect.DeepEqual(output, tc.Output) {
|
||||
t.Fatalf("Got:\n\n%#v\n\nExpected:\n\n%#v", output, tc.Output)
|
||||
}
|
||||
|
@ -259,9 +259,9 @@ func TestFlattenHealthCheck(t *testing.T) {
|
|||
func TestExpandStringList(t *testing.T) {
|
||||
expanded := flatmap.Expand(testConf(), "availability_zones").([]interface{})
|
||||
stringList := expandStringList(expanded)
|
||||
expected := []string{
|
||||
"us-east-1a",
|
||||
"us-east-1b",
|
||||
expected := []*string{
|
||||
aws.String("us-east-1a"),
|
||||
aws.String("us-east-1b"),
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(stringList, expected) {
|
||||
|
@ -273,7 +273,7 @@ func TestExpandStringList(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestExpandParameters(t *testing.T) {
|
||||
func TestexpandParameters(t *testing.T) {
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
"name": "character_set_client",
|
||||
|
@ -286,7 +286,7 @@ func TestExpandParameters(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
|
||||
expected := rds.Parameter{
|
||||
expected := &rds.Parameter{
|
||||
ParameterName: aws.String("character_set_client"),
|
||||
ParameterValue: aws.String("utf8"),
|
||||
ApplyMethod: aws.String("immediate"),
|
||||
|
@ -300,14 +300,14 @@ func TestExpandParameters(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFlattenParameters(t *testing.T) {
|
||||
func TestflattenParameters(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input []rds.Parameter
|
||||
Input []*rds.Parameter
|
||||
Output []map[string]interface{}
|
||||
}{
|
||||
{
|
||||
Input: []rds.Parameter{
|
||||
rds.Parameter{
|
||||
Input: []*rds.Parameter{
|
||||
&rds.Parameter{
|
||||
ParameterName: aws.String("character_set_client"),
|
||||
ParameterValue: aws.String("utf8"),
|
||||
},
|
||||
|
@ -329,11 +329,11 @@ func TestFlattenParameters(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpandInstanceString(t *testing.T) {
|
||||
func TestexpandInstanceString(t *testing.T) {
|
||||
|
||||
expected := []elb.Instance{
|
||||
elb.Instance{aws.String("test-one")},
|
||||
elb.Instance{aws.String("test-two")},
|
||||
expected := []*elb.Instance{
|
||||
&elb.Instance{InstanceID: aws.String("test-one")},
|
||||
&elb.Instance{InstanceID: aws.String("test-two")},
|
||||
}
|
||||
|
||||
ids := []interface{}{
|
||||
|
@ -348,10 +348,10 @@ func TestExpandInstanceString(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFlattenNetworkInterfacesPrivateIPAddesses(t *testing.T) {
|
||||
expanded := []ec2.NetworkInterfacePrivateIPAddress{
|
||||
ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.1")},
|
||||
ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.2")},
|
||||
func TestflattenNetworkInterfacesPrivateIPAddesses(t *testing.T) {
|
||||
expanded := []*ec2.NetworkInterfacePrivateIPAddress{
|
||||
&ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.1")},
|
||||
&ec2.NetworkInterfacePrivateIPAddress{PrivateIPAddress: aws.String("192.168.0.2")},
|
||||
}
|
||||
|
||||
result := flattenNetworkInterfacesPrivateIPAddesses(expanded)
|
||||
|
@ -373,10 +373,10 @@ func TestFlattenNetworkInterfacesPrivateIPAddesses(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFlattenGroupIdentifiers(t *testing.T) {
|
||||
expanded := []ec2.GroupIdentifier{
|
||||
ec2.GroupIdentifier{GroupID: aws.String("sg-001")},
|
||||
ec2.GroupIdentifier{GroupID: aws.String("sg-002")},
|
||||
func TestflattenGroupIdentifiers(t *testing.T) {
|
||||
expanded := []*ec2.GroupIdentifier{
|
||||
&ec2.GroupIdentifier{GroupID: aws.String("sg-001")},
|
||||
&ec2.GroupIdentifier{GroupID: aws.String("sg-002")},
|
||||
}
|
||||
|
||||
result := flattenGroupIdentifiers(expanded)
|
||||
|
@ -394,7 +394,7 @@ func TestFlattenGroupIdentifiers(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpandPrivateIPAddesses(t *testing.T) {
|
||||
func TestexpandPrivateIPAddesses(t *testing.T) {
|
||||
|
||||
ip1 := "192.168.0.1"
|
||||
ip2 := "192.168.0.2"
|
||||
|
@ -418,10 +418,10 @@ func TestExpandPrivateIPAddesses(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFlattenAttachment(t *testing.T) {
|
||||
func TestflattenAttachment(t *testing.T) {
|
||||
expanded := &ec2.NetworkInterfaceAttachment{
|
||||
InstanceID: aws.String("i-00001"),
|
||||
DeviceIndex: aws.Integer(1),
|
||||
DeviceIndex: aws.Long(int64(1)),
|
||||
AttachmentID: aws.String("at-002"),
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ func TestFlattenAttachment(t *testing.T) {
|
|||
t.Fatalf("expected instance to be i-00001, but got %s", result["instance"])
|
||||
}
|
||||
|
||||
if result["device_index"] != 1 {
|
||||
if result["device_index"] != int64(1) {
|
||||
t.Fatalf("expected device_index to be 1, but got %d", result["device_index"])
|
||||
}
|
||||
|
||||
|
@ -445,11 +445,11 @@ func TestFlattenAttachment(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFlattenResourceRecords(t *testing.T) {
|
||||
expanded := []route53.ResourceRecord{
|
||||
route53.ResourceRecord{
|
||||
expanded := []*route53.ResourceRecord{
|
||||
&route53.ResourceRecord{
|
||||
Value: aws.String("127.0.0.1"),
|
||||
},
|
||||
route53.ResourceRecord{
|
||||
&route53.ResourceRecord{
|
||||
Value: aws.String("127.0.0.3"),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package aws
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -19,18 +19,18 @@ func tagsSchema() *schema.Schema {
|
|||
|
||||
// setTags is a helper to set the tags for a resource. It expects the
|
||||
// tags field to be named "tags"
|
||||
func setTags(conn *ec2.EC2, d *schema.ResourceData) error {
|
||||
func setTagsSDK(conn *ec2.EC2, d *schema.ResourceData) error {
|
||||
if d.HasChange("tags") {
|
||||
oraw, nraw := d.GetChange("tags")
|
||||
o := oraw.(map[string]interface{})
|
||||
n := nraw.(map[string]interface{})
|
||||
create, remove := diffTags(tagsFromMap(o), tagsFromMap(n))
|
||||
create, remove := diffTagsSDK(tagsFromMapSDK(o), tagsFromMapSDK(n))
|
||||
|
||||
// Set tags
|
||||
if len(remove) > 0 {
|
||||
log.Printf("[DEBUG] Removing tags: %#v", remove)
|
||||
err := conn.DeleteTags(&ec2.DeleteTagsRequest{
|
||||
Resources: []string{d.Id()},
|
||||
_, err := conn.DeleteTags(&ec2.DeleteTagsInput{
|
||||
Resources: []*string{aws.String(d.Id())},
|
||||
Tags: remove,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -39,8 +39,8 @@ func setTags(conn *ec2.EC2, d *schema.ResourceData) error {
|
|||
}
|
||||
if len(create) > 0 {
|
||||
log.Printf("[DEBUG] Creating tags: %#v", create)
|
||||
err := conn.CreateTags(&ec2.CreateTagsRequest{
|
||||
Resources: []string{d.Id()},
|
||||
_, err := conn.CreateTags(&ec2.CreateTagsInput{
|
||||
Resources: []*string{aws.String(d.Id())},
|
||||
Tags: create,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -55,7 +55,7 @@ func setTags(conn *ec2.EC2, d *schema.ResourceData) error {
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTags(oldTags, newTags []ec2.Tag) ([]ec2.Tag, []ec2.Tag) {
|
||||
func diffTagsSDK(oldTags, newTags []*ec2.Tag) ([]*ec2.Tag, []*ec2.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -63,7 +63,7 @@ func diffTags(oldTags, newTags []ec2.Tag) ([]ec2.Tag, []ec2.Tag) {
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []ec2.Tag
|
||||
var remove []*ec2.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
|
@ -72,14 +72,14 @@ func diffTags(oldTags, newTags []ec2.Tag) ([]ec2.Tag, []ec2.Tag) {
|
|||
}
|
||||
}
|
||||
|
||||
return tagsFromMap(create), remove
|
||||
return tagsFromMapSDK(create), remove
|
||||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMap(m map[string]interface{}) []ec2.Tag {
|
||||
result := make([]ec2.Tag, 0, len(m))
|
||||
func tagsFromMapSDK(m map[string]interface{}) []*ec2.Tag {
|
||||
result := make([]*ec2.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, ec2.Tag{
|
||||
result = append(result, &ec2.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
|
@ -89,7 +89,7 @@ func tagsFromMap(m map[string]interface{}) []ec2.Tag {
|
|||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMap(ts []ec2.Tag) map[string]string {
|
||||
func tagsToMapSDK(ts []*ec2.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
|
|
|
@ -3,8 +3,8 @@ package aws
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -20,12 +20,12 @@ func setTagsELB(conn *elb.ELB, d *schema.ResourceData) error {
|
|||
// Set tags
|
||||
if len(remove) > 0 {
|
||||
log.Printf("[DEBUG] Removing tags: %#v", remove)
|
||||
k := make([]elb.TagKeyOnly, 0, len(remove))
|
||||
k := make([]*elb.TagKeyOnly, 0, len(remove))
|
||||
for _, t := range remove {
|
||||
k = append(k, elb.TagKeyOnly{Key: t.Key})
|
||||
k = append(k, &elb.TagKeyOnly{Key: t.Key})
|
||||
}
|
||||
_, err := conn.RemoveTags(&elb.RemoveTagsInput{
|
||||
LoadBalancerNames: []string{d.Get("name").(string)},
|
||||
LoadBalancerNames: []*string{aws.String(d.Get("name").(string))},
|
||||
Tags: k,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -35,7 +35,7 @@ func setTagsELB(conn *elb.ELB, d *schema.ResourceData) error {
|
|||
if len(create) > 0 {
|
||||
log.Printf("[DEBUG] Creating tags: %#v", create)
|
||||
_, err := conn.AddTags(&elb.AddTagsInput{
|
||||
LoadBalancerNames: []string{d.Get("name").(string)},
|
||||
LoadBalancerNames: []*string{aws.String(d.Get("name").(string))},
|
||||
Tags: create,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -50,7 +50,7 @@ func setTagsELB(conn *elb.ELB, d *schema.ResourceData) error {
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTagsELB(oldTags, newTags []elb.Tag) ([]elb.Tag, []elb.Tag) {
|
||||
func diffTagsELB(oldTags, newTags []*elb.Tag) ([]*elb.Tag, []*elb.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -58,7 +58,7 @@ func diffTagsELB(oldTags, newTags []elb.Tag) ([]elb.Tag, []elb.Tag) {
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []elb.Tag
|
||||
var remove []*elb.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
|
@ -71,10 +71,10 @@ func diffTagsELB(oldTags, newTags []elb.Tag) ([]elb.Tag, []elb.Tag) {
|
|||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMapELB(m map[string]interface{}) []elb.Tag {
|
||||
result := make([]elb.Tag, 0, len(m))
|
||||
func tagsFromMapELB(m map[string]interface{}) []*elb.Tag {
|
||||
result := make([]*elb.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, elb.Tag{
|
||||
result = append(result, &elb.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
|
@ -84,7 +84,7 @@ func tagsFromMapELB(m map[string]interface{}) []elb.Tag {
|
|||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMapELB(ts []elb.Tag) map[string]string {
|
||||
func tagsToMapELB(ts []*elb.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/elb"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ func TestDiffELBTags(t *testing.T) {
|
|||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckELBTags(
|
||||
ts *[]elb.Tag, key string, value string) resource.TestCheckFunc {
|
||||
ts *[]*elb.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMapELB(*ts)
|
||||
v, ok := m[key]
|
||||
|
|
|
@ -3,8 +3,8 @@ package aws
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -20,12 +20,12 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
|
|||
// Set tags
|
||||
if len(remove) > 0 {
|
||||
log.Printf("[DEBUG] Removing tags: %#v", remove)
|
||||
k := make([]string, len(remove), len(remove))
|
||||
k := make([]*string, len(remove), len(remove))
|
||||
for i, t := range remove {
|
||||
k[i] = *t.Key
|
||||
k[i] = t.Key
|
||||
}
|
||||
|
||||
err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceMessage{
|
||||
_, err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceInput{
|
||||
ResourceName: aws.String(arn),
|
||||
TagKeys: k,
|
||||
})
|
||||
|
@ -35,7 +35,7 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
|
|||
}
|
||||
if len(create) > 0 {
|
||||
log.Printf("[DEBUG] Creating tags: %#v", create)
|
||||
err := conn.AddTagsToResource(&rds.AddTagsToResourceMessage{
|
||||
_, err := conn.AddTagsToResource(&rds.AddTagsToResourceInput{
|
||||
ResourceName: aws.String(arn),
|
||||
Tags: create,
|
||||
})
|
||||
|
@ -51,7 +51,7 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
|
||||
func diffTagsRDS(oldTags, newTags []*rds.Tag) ([]*rds.Tag, []*rds.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -59,7 +59,7 @@ func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []rds.Tag
|
||||
var remove []*rds.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
|
@ -72,10 +72,10 @@ func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
|
|||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMapRDS(m map[string]interface{}) []rds.Tag {
|
||||
result := make([]rds.Tag, 0, len(m))
|
||||
func tagsFromMapRDS(m map[string]interface{}) []*rds.Tag {
|
||||
result := make([]*rds.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, rds.Tag{
|
||||
result = append(result, &rds.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ func tagsFromMapRDS(m map[string]interface{}) []rds.Tag {
|
|||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMapRDS(ts []rds.Tag) map[string]string {
|
||||
func tagsToMapRDS(ts []*rds.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -63,9 +63,9 @@ func TestDiffRDSTags(t *testing.T) {
|
|||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckRDSTags(
|
||||
ts *[]rds.Tag, key string, value string) resource.TestCheckFunc {
|
||||
ts []*rds.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMapRDS(*ts)
|
||||
m := tagsToMapRDS(ts)
|
||||
v, ok := m[key]
|
||||
if value != "" && !ok {
|
||||
return fmt.Errorf("Missing tag: %s", key)
|
||||
|
|
|
@ -3,8 +3,8 @@ package aws
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/aws"
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -18,16 +18,21 @@ func setTagsR53(conn *route53.Route53, d *schema.ResourceData) error {
|
|||
create, remove := diffTagsR53(tagsFromMapR53(o), tagsFromMapR53(n))
|
||||
|
||||
// Set tags
|
||||
r := make([]string, len(remove))
|
||||
r := make([]*string, len(remove))
|
||||
for i, t := range remove {
|
||||
r[i] = *t.Key
|
||||
r[i] = t.Key
|
||||
}
|
||||
log.Printf("[DEBUG] Changing tags: \n\tadding: %#v\n\tremoving:%#v", create, remove)
|
||||
req := &route53.ChangeTagsForResourceRequest{
|
||||
AddTags: create,
|
||||
RemoveTagKeys: r,
|
||||
ResourceID: aws.String(d.Id()),
|
||||
ResourceType: aws.String("hostedzone"),
|
||||
req := &route53.ChangeTagsForResourceInput{
|
||||
ResourceID: aws.String(d.Id()),
|
||||
ResourceType: aws.String("hostedzone"),
|
||||
}
|
||||
|
||||
if len(create) > 0 {
|
||||
req.AddTags = create
|
||||
}
|
||||
if len(r) > 0 {
|
||||
req.RemoveTagKeys = r
|
||||
}
|
||||
|
||||
_, err := conn.ChangeTagsForResource(req)
|
||||
|
@ -42,7 +47,7 @@ func setTagsR53(conn *route53.Route53, d *schema.ResourceData) error {
|
|||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTagsR53(oldTags, newTags []route53.Tag) ([]route53.Tag, []route53.Tag) {
|
||||
func diffTagsR53(oldTags, newTags []*route53.Tag) ([]*route53.Tag, []*route53.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
|
@ -50,7 +55,7 @@ func diffTagsR53(oldTags, newTags []route53.Tag) ([]route53.Tag, []route53.Tag)
|
|||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []route53.Tag
|
||||
var remove []*route53.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
|
@ -63,10 +68,10 @@ func diffTagsR53(oldTags, newTags []route53.Tag) ([]route53.Tag, []route53.Tag)
|
|||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMapR53(m map[string]interface{}) []route53.Tag {
|
||||
result := make([]route53.Tag, 0, len(m))
|
||||
func tagsFromMapR53(m map[string]interface{}) []*route53.Tag {
|
||||
result := make([]*route53.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, route53.Tag{
|
||||
result = append(result, &route53.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
|
@ -76,7 +81,7 @@ func tagsFromMapR53(m map[string]interface{}) []route53.Tag {
|
|||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMapR53(ts []route53.Tag) map[string]string {
|
||||
func tagsToMapR53(ts []*route53.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/route53"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ func TestDiffTagsR53(t *testing.T) {
|
|||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckTagsR53(
|
||||
ts *[]route53.Tag, key string, value string) resource.TestCheckFunc {
|
||||
ts *[]*route53.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMapR53(*ts)
|
||||
v, ok := m[key]
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
// tagsSchema returns the schema to use for tags.
|
||||
//
|
||||
// func tagsSchema() *schema.Schema {
|
||||
// return &schema.Schema{
|
||||
// Type: schema.TypeMap,
|
||||
// Optional: true,
|
||||
// }
|
||||
// }
|
||||
|
||||
// setTags is a helper to set the tags for a resource. It expects the
|
||||
// tags field to be named "tags"
|
||||
func setTagsSDK(conn *ec2.EC2, d *schema.ResourceData) error {
|
||||
if d.HasChange("tags") {
|
||||
oraw, nraw := d.GetChange("tags")
|
||||
o := oraw.(map[string]interface{})
|
||||
n := nraw.(map[string]interface{})
|
||||
create, remove := diffTagsSDK(tagsFromMapSDK(o), tagsFromMapSDK(n))
|
||||
|
||||
// Set tags
|
||||
if len(remove) > 0 {
|
||||
log.Printf("[DEBUG] Removing tags: %#v", remove)
|
||||
_, err := conn.DeleteTags(&ec2.DeleteTagsInput{
|
||||
Resources: []*string{aws.String(d.Id())},
|
||||
Tags: remove,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(create) > 0 {
|
||||
log.Printf("[DEBUG] Creating tags: %#v", create)
|
||||
_, err := conn.CreateTags(&ec2.CreateTagsInput{
|
||||
Resources: []*string{aws.String(d.Id())},
|
||||
Tags: create,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// diffTags takes our tags locally and the ones remotely and returns
|
||||
// the set of tags that must be created, and the set of tags that must
|
||||
// be destroyed.
|
||||
func diffTagsSDK(oldTags, newTags []*ec2.Tag) ([]*ec2.Tag, []*ec2.Tag) {
|
||||
// First, we're creating everything we have
|
||||
create := make(map[string]interface{})
|
||||
for _, t := range newTags {
|
||||
create[*t.Key] = *t.Value
|
||||
}
|
||||
|
||||
// Build the list of what to remove
|
||||
var remove []*ec2.Tag
|
||||
for _, t := range oldTags {
|
||||
old, ok := create[*t.Key]
|
||||
if !ok || old != *t.Value {
|
||||
// Delete it!
|
||||
remove = append(remove, t)
|
||||
}
|
||||
}
|
||||
|
||||
return tagsFromMapSDK(create), remove
|
||||
}
|
||||
|
||||
// tagsFromMap returns the tags for the given map of data.
|
||||
func tagsFromMapSDK(m map[string]interface{}) []*ec2.Tag {
|
||||
result := make([]*ec2.Tag, 0, len(m))
|
||||
for k, v := range m {
|
||||
result = append(result, &ec2.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v.(string)),
|
||||
})
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// tagsToMap turns the list of tags into a map.
|
||||
func tagsToMapSDK(ts []*ec2.Tag) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for _, t := range ts {
|
||||
result[*t.Key] = *t.Value
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestDiffTagsSDK(t *testing.T) {
|
||||
cases := []struct {
|
||||
Old, New map[string]interface{}
|
||||
Create, Remove map[string]string
|
||||
}{
|
||||
// Basic add/remove
|
||||
{
|
||||
Old: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
New: map[string]interface{}{
|
||||
"bar": "baz",
|
||||
},
|
||||
Create: map[string]string{
|
||||
"bar": "baz",
|
||||
},
|
||||
Remove: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
|
||||
// Modify
|
||||
{
|
||||
Old: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
New: map[string]interface{}{
|
||||
"foo": "baz",
|
||||
},
|
||||
Create: map[string]string{
|
||||
"foo": "baz",
|
||||
},
|
||||
Remove: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
c, r := diffTagsSDK(tagsFromMapSDK(tc.Old), tagsFromMapSDK(tc.New))
|
||||
cm := tagsToMapSDK(c)
|
||||
rm := tagsToMapSDK(r)
|
||||
if !reflect.DeepEqual(cm, tc.Create) {
|
||||
t.Fatalf("%d: bad create: %#v", i, cm)
|
||||
}
|
||||
if !reflect.DeepEqual(rm, tc.Remove) {
|
||||
t.Fatalf("%d: bad remove: %#v", i, rm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckTagsSDK(
|
||||
ts *[]*ec2.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMapSDK(*ts)
|
||||
v, ok := m[key]
|
||||
if value != "" && !ok {
|
||||
return fmt.Errorf("Missing tag: %s", key)
|
||||
} else if value == "" && ok {
|
||||
return fmt.Errorf("Extra tag: %s", key)
|
||||
}
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if v != value {
|
||||
return fmt.Errorf("%s: bad value: %s", key, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/aws-sdk-go/gen/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestDiffTags(t *testing.T) {
|
||||
func TestDiffTagsSDK(t *testing.T) {
|
||||
cases := []struct {
|
||||
Old, New map[string]interface{}
|
||||
Create, Remove map[string]string
|
||||
|
@ -49,9 +49,9 @@ func TestDiffTags(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
c, r := diffTags(tagsFromMap(tc.Old), tagsFromMap(tc.New))
|
||||
cm := tagsToMap(c)
|
||||
rm := tagsToMap(r)
|
||||
c, r := diffTagsSDK(tagsFromMapSDK(tc.Old), tagsFromMapSDK(tc.New))
|
||||
cm := tagsToMapSDK(c)
|
||||
rm := tagsToMapSDK(r)
|
||||
if !reflect.DeepEqual(cm, tc.Create) {
|
||||
t.Fatalf("%d: bad create: %#v", i, cm)
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ func TestDiffTags(t *testing.T) {
|
|||
}
|
||||
|
||||
// testAccCheckTags can be used to check the tags on a resource.
|
||||
func testAccCheckTags(
|
||||
ts *[]ec2.Tag, key string, value string) resource.TestCheckFunc {
|
||||
func testAccCheckTagsSDK(
|
||||
ts *[]*ec2.Tag, key string, value string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
m := tagsToMap(*ts)
|
||||
m := tagsToMapSDK(*ts)
|
||||
v, ok := m[key]
|
||||
if value != "" && !ok {
|
||||
return fmt.Errorf("Missing tag: %s", key)
|
||||
|
|
|
@ -6,7 +6,10 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
// TODO(dcunnin): Use version code from version.go
|
||||
// "github.com/hashicorp/terraform"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google"
|
||||
"golang.org/x/oauth2/jwt"
|
||||
|
@ -83,6 +86,17 @@ func (c *Config) loadAndValidate() error {
|
|||
log.Printf("[INFO] Instantiating GCE client...")
|
||||
var err error
|
||||
c.clientCompute, err = compute.New(client)
|
||||
|
||||
// Set UserAgent
|
||||
versionString := "0.0.0"
|
||||
// TODO(dcunnin): Use Terraform's version code from version.go
|
||||
// versionString := main.Version
|
||||
// if main.VersionPrerelease != "" {
|
||||
// versionString = fmt.Sprintf("%s-%s", versionString, main.VersionPrerelease)
|
||||
// }
|
||||
c.clientCompute.UserAgent = fmt.Sprintf(
|
||||
"(%s %s) Terraform/%s", runtime.GOOS, runtime.GOARCH, versionString)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ func resourceComputeInstance() *schema.Resource {
|
|||
Update: resourceComputeInstanceUpdate,
|
||||
Delete: resourceComputeInstanceDelete,
|
||||
|
||||
SchemaVersion: 1,
|
||||
MigrateState: resourceComputeInstanceMigrateState,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -168,11 +171,9 @@ func resourceComputeInstance() *schema.Resource {
|
|||
},
|
||||
|
||||
"metadata": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Type: schema.TypeMap,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeMap,
|
||||
},
|
||||
Elem: schema.TypeString,
|
||||
},
|
||||
|
||||
"service_account": &schema.Schema{
|
||||
|
@ -735,6 +736,7 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
|
|||
config := meta.(*Config)
|
||||
|
||||
zone := d.Get("zone").(string)
|
||||
log.Printf("[INFO] Requesting instance deletion: %s", d.Id())
|
||||
op, err := config.clientCompute.Instances.Delete(config.Project, zone, d.Id()).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting instance: %s", err)
|
||||
|
@ -751,32 +753,22 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
|
|||
}
|
||||
|
||||
func resourceInstanceMetadata(d *schema.ResourceData) *compute.Metadata {
|
||||
var metadata *compute.Metadata
|
||||
if metadataList := d.Get("metadata").([]interface{}); len(metadataList) > 0 {
|
||||
m := new(compute.Metadata)
|
||||
m.Items = make([]*compute.MetadataItems, 0, len(metadataList))
|
||||
for _, metadataMap := range metadataList {
|
||||
for key, val := range metadataMap.(map[string]interface{}) {
|
||||
// TODO: fix https://github.com/hashicorp/terraform/issues/883
|
||||
// and remove this workaround <3 phinze
|
||||
if key == "#" {
|
||||
continue
|
||||
}
|
||||
m.Items = append(m.Items, &compute.MetadataItems{
|
||||
Key: key,
|
||||
Value: val.(string),
|
||||
})
|
||||
}
|
||||
m := &compute.Metadata{}
|
||||
if mdMap := d.Get("metadata").(map[string]interface{}); len(mdMap) > 0 {
|
||||
m.Items = make([]*compute.MetadataItems, 0, len(mdMap))
|
||||
for key, val := range mdMap {
|
||||
m.Items = append(m.Items, &compute.MetadataItems{
|
||||
Key: key,
|
||||
Value: val.(string),
|
||||
})
|
||||
}
|
||||
|
||||
// Set the fingerprint. If the metadata has never been set before
|
||||
// then this will just be blank.
|
||||
m.Fingerprint = d.Get("metadata_fingerprint").(string)
|
||||
|
||||
metadata = m
|
||||
}
|
||||
|
||||
return metadata
|
||||
return m
|
||||
}
|
||||
|
||||
func resourceInstanceTags(d *schema.ResourceData) *compute.Tags {
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func resourceComputeInstanceMigrateState(
|
||||
v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
|
||||
if is.Empty() {
|
||||
log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
|
||||
return is, nil
|
||||
}
|
||||
|
||||
switch v {
|
||||
case 0:
|
||||
log.Println("[INFO] Found Compute Instance State v0; migrating to v1")
|
||||
return migrateStateV0toV1(is)
|
||||
default:
|
||||
return is, fmt.Errorf("Unexpected schema version: %d", v)
|
||||
}
|
||||
}
|
||||
|
||||
func migrateStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {
|
||||
log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)
|
||||
|
||||
// Delete old count
|
||||
delete(is.Attributes, "metadata.#")
|
||||
|
||||
newMetadata := make(map[string]string)
|
||||
|
||||
for k, v := range is.Attributes {
|
||||
if !strings.HasPrefix(k, "metadata.") {
|
||||
continue
|
||||
}
|
||||
|
||||
// We have a key that looks like "metadata.*" and we know it's not
|
||||
// metadata.# because we deleted it above, so it must be metadata.<N>.<key>
|
||||
// from the List of Maps. Just need to convert it to a single Map by
|
||||
// ditching the '<N>' field.
|
||||
kParts := strings.SplitN(k, ".", 3)
|
||||
|
||||
// Sanity check: all three parts should be there and <N> should be a number
|
||||
badFormat := false
|
||||
if len(kParts) != 3 {
|
||||
badFormat = true
|
||||
} else if _, err := strconv.Atoi(kParts[1]); err != nil {
|
||||
badFormat = true
|
||||
}
|
||||
|
||||
if badFormat {
|
||||
return is, fmt.Errorf(
|
||||
"migration error: found metadata key in unexpected format: %s", k)
|
||||
}
|
||||
|
||||
// Rejoin as "metadata.<key>"
|
||||
newK := strings.Join([]string{kParts[0], kParts[2]}, ".")
|
||||
newMetadata[newK] = v
|
||||
delete(is.Attributes, k)
|
||||
}
|
||||
|
||||
for k, v := range newMetadata {
|
||||
is.Attributes[k] = v
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes)
|
||||
return is, nil
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestComputeInstanceMigrateState(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
StateVersion int
|
||||
Attributes map[string]string
|
||||
Expected map[string]string
|
||||
Meta interface{}
|
||||
}{
|
||||
"v0.4.2 and earlier": {
|
||||
StateVersion: 0,
|
||||
Attributes: map[string]string{
|
||||
"metadata.#": "2",
|
||||
"metadata.0.foo": "bar",
|
||||
"metadata.1.baz": "qux",
|
||||
"metadata.2.with.dots": "should.work",
|
||||
},
|
||||
Expected: map[string]string{
|
||||
"metadata.foo": "bar",
|
||||
"metadata.baz": "qux",
|
||||
"metadata.with.dots": "should.work",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for tn, tc := range cases {
|
||||
is := &terraform.InstanceState{
|
||||
ID: "i-abc123",
|
||||
Attributes: tc.Attributes,
|
||||
}
|
||||
is, err := resourceComputeInstanceMigrateState(
|
||||
tc.StateVersion, is, tc.Meta)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %s, err: %#v", tn, err)
|
||||
}
|
||||
|
||||
for k, v := range tc.Expected {
|
||||
if is.Attributes[k] != v {
|
||||
t.Fatalf(
|
||||
"bad: %s\n\n expected: %#v -> %#v\n got: %#v -> %#v\n in: %#v",
|
||||
tn, k, v, k, is.Attributes[k], is.Attributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeInstanceMigrateState_empty(t *testing.T) {
|
||||
var is *terraform.InstanceState
|
||||
var meta interface{}
|
||||
|
||||
// should handle nil
|
||||
is, err := resourceComputeInstanceMigrateState(0, is, meta)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("err: %#v", err)
|
||||
}
|
||||
if is != nil {
|
||||
t.Fatalf("expected nil instancestate, got: %#v", is)
|
||||
}
|
||||
|
||||
// should handle non-nil but empty
|
||||
is = &terraform.InstanceState{}
|
||||
is, err = resourceComputeInstanceMigrateState(0, is, meta)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("err: %#v", err)
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ func TestAccComputeInstance_basic(t *testing.T) {
|
|||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceTag(&instance, "foo"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "foo", "bar"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "baz", "qux"),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
),
|
||||
},
|
||||
|
@ -168,6 +169,34 @@ func TestAccComputeInstance_update_deprecated_network(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccComputeInstance_forceNewAndChangeMetadata(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_forceNewAndChangeMetadata,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceMetadata(
|
||||
&instance, "qux", "true"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccComputeInstance_update(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
|
||||
|
@ -387,6 +416,9 @@ resource "google_compute_instance" "foobar" {
|
|||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
metadata {
|
||||
baz = "qux"
|
||||
}
|
||||
}`
|
||||
|
||||
const testAccComputeInstance_basic2 = `
|
||||
|
@ -432,6 +464,30 @@ resource "google_compute_instance" "foobar" {
|
|||
}
|
||||
}`
|
||||
|
||||
// Update zone to ForceNew, and change metadata k/v entirely
|
||||
// Generates diff mismatch
|
||||
const testAccComputeInstance_forceNewAndChangeMetadata = `
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "terraform-test"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
zone = "us-central1-b"
|
||||
tags = ["baz"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config { }
|
||||
}
|
||||
|
||||
metadata {
|
||||
qux = "true"
|
||||
}
|
||||
}`
|
||||
|
||||
// Update metadata, tags, and network_interface
|
||||
const testAccComputeInstance_update = `
|
||||
resource "google_compute_instance" "foobar" {
|
||||
|
|
|
@ -8,6 +8,7 @@ func canonicalizeServiceScope(scope string) string {
|
|||
"compute-ro": "https://www.googleapis.com/auth/compute.readonly",
|
||||
"compute-rw": "https://www.googleapis.com/auth/compute",
|
||||
"datastore": "https://www.googleapis.com/auth/datastore",
|
||||
"logging-write": "https://www.googleapis.com/auth/logging.write",
|
||||
"sql": "https://www.googleapis.com/auth/sqlservice",
|
||||
"sql-admin": "https://www.googleapis.com/auth/sqlservice.admin",
|
||||
"storage-full": "https://www.googleapis.com/auth/devstorage.full_control",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package openstack
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/openstack"
|
||||
)
|
||||
|
@ -15,6 +18,7 @@ type Config struct {
|
|||
TenantName string
|
||||
DomainID string
|
||||
DomainName string
|
||||
Insecure bool
|
||||
|
||||
osClient *gophercloud.ProviderClient
|
||||
}
|
||||
|
@ -32,7 +36,19 @@ func (c *Config) loadAndValidate() error {
|
|||
DomainName: c.DomainName,
|
||||
}
|
||||
|
||||
client, err := openstack.AuthenticatedClient(ao)
|
||||
client, err := openstack.NewClient(ao.IdentityEndpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.Insecure {
|
||||
// Configure custom TLS settings.
|
||||
config := &tls.Config{InsecureSkipVerify: true}
|
||||
transport := &http.Transport{TLSClientConfig: config}
|
||||
client.HTTPClient.Transport = transport
|
||||
}
|
||||
|
||||
err = openstack.Authenticate(client, ao)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -56,6 +56,11 @@ func Provider() terraform.ResourceProvider {
|
|||
Optional: true,
|
||||
Default: "",
|
||||
},
|
||||
"insecure": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
},
|
||||
|
||||
ResourcesMap: map[string]*schema.Resource{
|
||||
|
@ -93,6 +98,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
|
|||
TenantName: d.Get("tenant_name").(string),
|
||||
DomainID: d.Get("domain_id").(string),
|
||||
DomainName: d.Get("domain_name").(string),
|
||||
Insecure: d.Get("insecure").(bool),
|
||||
}
|
||||
|
||||
if err := config.loadAndValidate(); err != nil {
|
||||
|
@ -111,3 +117,10 @@ func envDefaultFunc(k string) schema.SchemaDefaultFunc {
|
|||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func envDefaultFuncAllowMissing(k string) schema.SchemaDefaultFunc {
|
||||
return func() (interface{}, error) {
|
||||
v := os.Getenv(k)
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,9 @@ func testAccPreCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
v = os.Getenv("OS_REGION_NAME")
|
||||
if v == "" {
|
||||
t.Fatal("OS_REGION_NAME must be set for acceptance tests")
|
||||
if v != "" {
|
||||
OS_REGION_NAME = v
|
||||
}
|
||||
OS_REGION_NAME = v
|
||||
|
||||
v1 := os.Getenv("OS_IMAGE_ID")
|
||||
v2 := os.Getenv("OS_IMAGE_NAME")
|
||||
|
|
|
@ -26,7 +26,7 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"size": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
|
|
|
@ -20,7 +20,7 @@ func resourceComputeFloatingIPV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
|
||||
"pool": &schema.Schema{
|
||||
|
|
|
@ -36,7 +36,7 @@ func resourceComputeInstanceV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -19,7 +19,7 @@ func resourceComputeKeypairV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -23,7 +23,7 @@ func resourceComputeSecGroupV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -23,7 +23,7 @@ func resourceFWFirewallV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -23,7 +23,7 @@ func resourceFWPolicyV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -21,7 +21,7 @@ func resourceFWRuleV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -21,7 +21,7 @@ func resourceLBMonitorV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -24,7 +24,7 @@ func resourceLBPoolV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -61,7 +61,7 @@ func resourceLBPoolV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -22,7 +22,7 @@ func resourceLBVipV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -21,7 +21,7 @@ func resourceNetworkingFloatingIPV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"address": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -21,7 +21,7 @@ func resourceNetworkingNetworkV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -21,7 +21,7 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"router_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -22,7 +22,7 @@ func resourceNetworkingRouterV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -22,7 +22,7 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"network_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -20,7 +20,7 @@ func resourceObjectStorageContainerV1() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
||||
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/config"
|
||||
helper "github.com/hashicorp/terraform/helper/ssh"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
type ResourceProvisioner struct{}
|
||||
|
@ -35,6 +36,11 @@ func (p *ResourceProvisioner) Apply(
|
|||
return fmt.Errorf("Unsupported 'source' type! Must be string.")
|
||||
}
|
||||
|
||||
src, err = homedir.Expand(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dRaw := c.Config["destination"]
|
||||
dst, ok := dRaw.(string)
|
||||
if !ok {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/terraform/state"
|
||||
|
@ -208,7 +209,7 @@ func remoteState(
|
|||
}
|
||||
|
||||
// Initialize the remote client based on the local state
|
||||
client, err := remote.NewClient(local.Remote.Type, local.Remote.Config)
|
||||
client, err := remote.NewClient(strings.ToLower(local.Remote.Type), local.Remote.Config)
|
||||
if err != nil {
|
||||
return nil, errwrap.Wrapf(fmt.Sprintf(
|
||||
"Error initializing remote driver '%s': {{err}}",
|
||||
|
|
|
@ -290,6 +290,14 @@ func (c *Config) Validate() error {
|
|||
raw[k] = strVal
|
||||
}
|
||||
|
||||
// Check for invalid count variables
|
||||
for _, v := range m.RawConfig.Variables {
|
||||
if _, ok := v.(*CountVariable); ok {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"%s: count variables are only valid within resources", m.Name))
|
||||
}
|
||||
}
|
||||
|
||||
// Update the raw configuration to only contain the string values
|
||||
m.RawConfig, err = NewRawConfig(raw)
|
||||
if err != nil {
|
||||
|
@ -472,6 +480,13 @@ func (c *Config) Validate() error {
|
|||
errs = append(errs, fmt.Errorf(
|
||||
"%s: output should only have 'value' field", o.Name))
|
||||
}
|
||||
|
||||
for _, v := range o.RawConfig.Variables {
|
||||
if _, ok := v.(*CountVariable); ok {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"%s: count variables are only valid within resources", o.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that all variables are in the proper context
|
||||
|
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -60,6 +61,22 @@ func TestConfigValidate_countInt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_countBadContext(t *testing.T) {
|
||||
c := testConfig(t, "validate-count-bad-context")
|
||||
|
||||
err := c.Validate()
|
||||
|
||||
expected := []string{
|
||||
"no_count_in_output: count variables are only valid within resources",
|
||||
"no_count_in_module: count variables are only valid within resources",
|
||||
}
|
||||
for _, exp := range expected {
|
||||
if !strings.Contains(err.Error(), exp) {
|
||||
t.Fatalf("expected: %q,\nto contain: %q", err, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_countCountVar(t *testing.T) {
|
||||
c := testConfig(t, "validate-count-count-var")
|
||||
if err := c.Validate(); err == nil {
|
||||
|
|
|
@ -23,6 +23,7 @@ func init() {
|
|||
"element": interpolationFuncElement(),
|
||||
"replace": interpolationFuncReplace(),
|
||||
"split": interpolationFuncSplit(),
|
||||
"length": interpolationFuncLength(),
|
||||
|
||||
// Concat is a little useless now since we supported embeddded
|
||||
// interpolations but we keep it around for backwards compat reasons.
|
||||
|
@ -132,6 +133,28 @@ func interpolationFuncReplace() ast.Function {
|
|||
}
|
||||
}
|
||||
|
||||
func interpolationFuncLength() ast.Function {
|
||||
return ast.Function{
|
||||
ArgTypes: []ast.Type{ast.TypeString},
|
||||
ReturnType: ast.TypeInt,
|
||||
Variadic: false,
|
||||
Callback: func(args []interface{}) (interface{}, error) {
|
||||
if !strings.Contains(args[0].(string), InterpSplitDelim) {
|
||||
return len(args[0].(string)), nil
|
||||
}
|
||||
|
||||
var list []string
|
||||
for _, arg := range args {
|
||||
parts := strings.Split(arg.(string), InterpSplitDelim)
|
||||
for _, part := range parts {
|
||||
list = append(list, part)
|
||||
}
|
||||
}
|
||||
return len(list), nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// interpolationFuncSplit implements the "split" function that allows
|
||||
// strings to split into multi-variable values
|
||||
func interpolationFuncSplit() ast.Function {
|
||||
|
|
|
@ -183,6 +183,66 @@ func TestInterpolateFuncReplace(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestInterpolateFuncLength(t *testing.T) {
|
||||
testFunction(t, testFunctionConfig{
|
||||
Cases: []testFunctionCase{
|
||||
// Raw strings
|
||||
{
|
||||
`${length("")}`,
|
||||
"0",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length("a")}`,
|
||||
"1",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(" ")}`,
|
||||
"1",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(" a ,")}`,
|
||||
"4",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length("aaa")}`,
|
||||
"3",
|
||||
false,
|
||||
},
|
||||
|
||||
// Lists
|
||||
{
|
||||
`${length(split(",", "a"))}`,
|
||||
"1",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(split(",", "foo,"))}`,
|
||||
"2",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(split(",", ",foo,"))}`,
|
||||
"3",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(split(",", "foo,bar"))}`,
|
||||
"2",
|
||||
false,
|
||||
},
|
||||
{
|
||||
`${length(split(".", "one.two.three.four.five"))}`,
|
||||
"5",
|
||||
false,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestInterpolateFuncSplit(t *testing.T) {
|
||||
testFunction(t, testFunctionConfig{
|
||||
Cases: []testFunctionCase{
|
||||
|
@ -198,6 +258,35 @@ func TestInterpolateFuncSplit(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
|
||||
{
|
||||
`${split(",", ",,,")}`,
|
||||
fmt.Sprintf(
|
||||
"%s%s%s",
|
||||
InterpSplitDelim,
|
||||
InterpSplitDelim,
|
||||
InterpSplitDelim),
|
||||
false,
|
||||
},
|
||||
|
||||
{
|
||||
`${split(",", "foo,")}`,
|
||||
fmt.Sprintf(
|
||||
"%s%s",
|
||||
"foo",
|
||||
InterpSplitDelim),
|
||||
false,
|
||||
},
|
||||
|
||||
{
|
||||
`${split(",", ",foo,")}`,
|
||||
fmt.Sprintf(
|
||||
"%s%s%s",
|
||||
InterpSplitDelim,
|
||||
"foo",
|
||||
InterpSplitDelim),
|
||||
false,
|
||||
},
|
||||
|
||||
{
|
||||
`${split(".", "foo.bar.baz")}`,
|
||||
fmt.Sprintf(
|
||||
|
|
|
@ -100,20 +100,29 @@ func (tc *typeCheckArithmetic) TypeCheck(v *TypeCheck) (ast.Node, error) {
|
|||
exprs[len(tc.n.Exprs)-1-i] = v.StackPop()
|
||||
}
|
||||
|
||||
// Determine the resulting type we want
|
||||
// Determine the resulting type we want. We do this by going over
|
||||
// every expression until we find one with a type we recognize.
|
||||
// We do this because the first expr might be a string ("var.foo")
|
||||
// and we need to know what to implicit to.
|
||||
mathFunc := "__builtin_IntMath"
|
||||
mathType := ast.TypeInt
|
||||
switch v := exprs[0]; v {
|
||||
case ast.TypeInt:
|
||||
mathFunc = "__builtin_IntMath"
|
||||
mathType = v
|
||||
case ast.TypeFloat:
|
||||
mathFunc = "__builtin_FloatMath"
|
||||
mathType = v
|
||||
default:
|
||||
return nil, fmt.Errorf(
|
||||
"Math operations can only be done with ints and floats, got %s",
|
||||
v)
|
||||
for _, v := range exprs {
|
||||
exit := true
|
||||
switch v {
|
||||
case ast.TypeInt:
|
||||
mathFunc = "__builtin_IntMath"
|
||||
mathType = v
|
||||
case ast.TypeFloat:
|
||||
mathFunc = "__builtin_FloatMath"
|
||||
mathType = v
|
||||
default:
|
||||
exit = false
|
||||
}
|
||||
|
||||
// We found the type, so leave
|
||||
if exit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the args
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue