Skip to content

Commit

Permalink
provider/aws: Update source to comply with upstream breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Jul 28, 2015
1 parent 476197f commit 579ccbe
Show file tree
Hide file tree
Showing 46 changed files with 236 additions and 247 deletions.
2 changes: 1 addition & 1 deletion builtin/providers/aws/autoscaling_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func autoscalingTagsFromMap(m map[string]interface{}, resourceID string) []*auto
result = append(result, &autoscaling.Tag{
Key: aws.String(k),
Value: aws.String(attr["value"].(string)),
PropagateAtLaunch: aws.Boolean(attr["propagate_at_launch"].(bool)),
PropagateAtLaunch: aws.Bool(attr["propagate_at_launch"].(bool)),
ResourceID: aws.String(resourceID),
ResourceType: aws.String("auto-scaling-group"),
})
Expand Down
8 changes: 4 additions & 4 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (c *Config) Client() (interface{}, error) {
creds := credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token)
awsConfig := &aws.Config{
Credentials: creds,
Region: c.Region,
MaxRetries: c.MaxRetries,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
}

log.Println("[INFO] Initializing IAM Connection")
Expand Down Expand Up @@ -135,8 +135,8 @@ func (c *Config) Client() (interface{}, error) {
log.Println("[INFO] Initializing Route 53 connection")
client.r53conn = route53.New(&aws.Config{
Credentials: creds,
Region: "us-east-1",
MaxRetries: c.MaxRetries,
Region: aws.String("us-east-1"),
MaxRetries: aws.Int(c.MaxRetries),
})

log.Println("[INFO] Initializing Elasticache Connection")
Expand Down
12 changes: 6 additions & 6 deletions builtin/providers/aws/network_acl_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ func expandNetworkAclEntries(configured []interface{}, entryType string) ([]*ec2
e := &ec2.NetworkACLEntry{
Protocol: aws.String(strconv.Itoa(p)),
PortRange: &ec2.PortRange{
From: aws.Long(int64(data["from_port"].(int))),
To: aws.Long(int64(data["to_port"].(int))),
From: aws.Int64(int64(data["from_port"].(int))),
To: aws.Int64(int64(data["to_port"].(int))),
},
Egress: aws.Boolean((entryType == "egress")),
Egress: aws.Bool((entryType == "egress")),
RuleAction: aws.String(data["action"].(string)),
RuleNumber: aws.Long(int64(data["rule_no"].(int))),
RuleNumber: aws.Int64(int64(data["rule_no"].(int))),
CIDRBlock: aws.String(data["cidr_block"].(string)),
}

// Specify additional required fields for ICMP
if p == 1 {
e.ICMPTypeCode = &ec2.ICMPTypeCode{}
if v, ok := data["icmp_code"]; ok {
e.ICMPTypeCode.Code = aws.Long(int64(v.(int)))
e.ICMPTypeCode.Code = aws.Int64(int64(v.(int)))
}
if v, ok := data["icmp_type"]; ok {
e.ICMPTypeCode.Type = aws.Long(int64(v.(int)))
e.ICMPTypeCode.Type = aws.Int64(int64(v.(int)))
}
}

Expand Down
36 changes: 18 additions & 18 deletions builtin/providers/aws/network_acl_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,35 @@ func Test_expandNetworkACLEntry(t *testing.T) {
&ec2.NetworkACLEntry{
Protocol: aws.String("6"),
PortRange: &ec2.PortRange{
From: aws.Long(22),
To: aws.Long(22),
From: aws.Int64(22),
To: aws.Int64(22),
},
RuleAction: aws.String("deny"),
RuleNumber: aws.Long(1),
RuleNumber: aws.Int64(1),
CIDRBlock: aws.String("0.0.0.0/0"),
Egress: aws.Boolean(true),
Egress: aws.Bool(true),
},
&ec2.NetworkACLEntry{
Protocol: aws.String("6"),
PortRange: &ec2.PortRange{
From: aws.Long(443),
To: aws.Long(443),
From: aws.Int64(443),
To: aws.Int64(443),
},
RuleAction: aws.String("deny"),
RuleNumber: aws.Long(2),
RuleNumber: aws.Int64(2),
CIDRBlock: aws.String("0.0.0.0/0"),
Egress: aws.Boolean(true),
Egress: aws.Bool(true),
},
&ec2.NetworkACLEntry{
Protocol: aws.String("-1"),
PortRange: &ec2.PortRange{
From: aws.Long(443),
To: aws.Long(443),
From: aws.Int64(443),
To: aws.Int64(443),
},
RuleAction: aws.String("deny"),
RuleNumber: aws.Long(2),
RuleNumber: aws.Int64(2),
CIDRBlock: aws.String("0.0.0.0/0"),
Egress: aws.Boolean(true),
Egress: aws.Bool(true),
},
}

Expand All @@ -88,21 +88,21 @@ func Test_flattenNetworkACLEntry(t *testing.T) {
&ec2.NetworkACLEntry{
Protocol: aws.String("tcp"),
PortRange: &ec2.PortRange{
From: aws.Long(22),
To: aws.Long(22),
From: aws.Int64(22),
To: aws.Int64(22),
},
RuleAction: aws.String("deny"),
RuleNumber: aws.Long(1),
RuleNumber: aws.Int64(1),
CIDRBlock: aws.String("0.0.0.0/0"),
},
&ec2.NetworkACLEntry{
Protocol: aws.String("tcp"),
PortRange: &ec2.PortRange{
From: aws.Long(443),
To: aws.Long(443),
From: aws.Int64(443),
To: aws.Int64(443),
},
RuleAction: aws.String("deny"),
RuleNumber: aws.Long(2),
RuleNumber: aws.Int64(2),
CIDRBlock: aws.String("0.0.0.0/0"),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func resourceAwsAppCookieStickinessPolicyCreate(d *schema.ResourceData, meta int

setLoadBalancerOpts := &elb.SetLoadBalancerPoliciesOfListenerInput{
LoadBalancerName: aws.String(d.Get("load_balancer").(string)),
LoadBalancerPort: aws.Long(int64(d.Get("lb_port").(int))),
LoadBalancerPort: aws.Int64(int64(d.Get("lb_port").(int))),
PolicyNames: []*string{aws.String(d.Get("name").(string))},
}

Expand Down Expand Up @@ -129,7 +129,7 @@ func resourceAwsAppCookieStickinessPolicyDelete(d *schema.ResourceData, meta int
// policy itself.
setLoadBalancerOpts := &elb.SetLoadBalancerPoliciesOfListenerInput{
LoadBalancerName: aws.String(d.Get("load_balancer").(string)),
LoadBalancerPort: aws.Long(int64(d.Get("lb_port").(int))),
LoadBalancerPort: aws.Int64(int64(d.Get("lb_port").(int))),
PolicyNames: []*string{},
}

Expand Down
30 changes: 15 additions & 15 deletions builtin/providers/aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
var autoScalingGroupOpts autoscaling.CreateAutoScalingGroupInput
autoScalingGroupOpts.AutoScalingGroupName = aws.String(d.Get("name").(string))
autoScalingGroupOpts.LaunchConfigurationName = aws.String(d.Get("launch_configuration").(string))
autoScalingGroupOpts.MinSize = aws.Long(int64(d.Get("min_size").(int)))
autoScalingGroupOpts.MaxSize = aws.Long(int64(d.Get("max_size").(int)))
autoScalingGroupOpts.MinSize = aws.Int64(int64(d.Get("min_size").(int)))
autoScalingGroupOpts.MaxSize = aws.Int64(int64(d.Get("max_size").(int)))

// Availability Zones are optional if VPC Zone Identifer(s) are specified
if v, ok := d.GetOk("availability_zones"); ok && v.(*schema.Set).Len() > 0 {
Expand All @@ -145,19 +145,19 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
}

if v, ok := d.GetOk("default_cooldown"); ok {
autoScalingGroupOpts.DefaultCooldown = aws.Long(int64(v.(int)))
autoScalingGroupOpts.DefaultCooldown = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("health_check_type"); ok && v.(string) != "" {
autoScalingGroupOpts.HealthCheckType = aws.String(v.(string))
}

if v, ok := d.GetOk("desired_capacity"); ok {
autoScalingGroupOpts.DesiredCapacity = aws.Long(int64(v.(int)))
autoScalingGroupOpts.DesiredCapacity = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("health_check_grace_period"); ok {
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Long(int64(v.(int)))
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
Expand Down Expand Up @@ -224,31 +224,31 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{})
}

if d.HasChange("default_cooldown") {
opts.DefaultCooldown = aws.Long(int64(d.Get("default_cooldown").(int)))
opts.DefaultCooldown = aws.Int64(int64(d.Get("default_cooldown").(int)))
}

if d.HasChange("desired_capacity") {
opts.DesiredCapacity = aws.Long(int64(d.Get("desired_capacity").(int)))
opts.DesiredCapacity = aws.Int64(int64(d.Get("desired_capacity").(int)))
}

if d.HasChange("launch_configuration") {
opts.LaunchConfigurationName = aws.String(d.Get("launch_configuration").(string))
}

if d.HasChange("min_size") {
opts.MinSize = aws.Long(int64(d.Get("min_size").(int)))
opts.MinSize = aws.Int64(int64(d.Get("min_size").(int)))
}

if d.HasChange("max_size") {
opts.MaxSize = aws.Long(int64(d.Get("max_size").(int)))
opts.MaxSize = aws.Int64(int64(d.Get("max_size").(int)))
}

if d.HasChange("health_check_grace_period") {
opts.HealthCheckGracePeriod = aws.Long(int64(d.Get("health_check_grace_period").(int)))
opts.HealthCheckGracePeriod = aws.Int64(int64(d.Get("health_check_grace_period").(int)))
}

if d.HasChange("health_check_type") {
opts.HealthCheckGracePeriod = aws.Long(int64(d.Get("health_check_grace_period").(int)))
opts.HealthCheckGracePeriod = aws.Int64(int64(d.Get("health_check_grace_period").(int)))
opts.HealthCheckType = aws.String(d.Get("health_check_type").(string))
}

Expand Down Expand Up @@ -342,7 +342,7 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{})
// and then delete the group. This bypasses that and leaves
// resources potentially dangling.
if d.Get("force_delete").(bool) {
deleteopts.ForceDelete = aws.Boolean(true)
deleteopts.ForceDelete = aws.Bool(true)
}

// We retry the delete operation to handle InUse/InProgress errors coming
Expand Down Expand Up @@ -418,9 +418,9 @@ func resourceAwsAutoscalingGroupDrain(d *schema.ResourceData, meta interface{})
log.Printf("[DEBUG] Reducing autoscaling group capacity to zero")
opts := autoscaling.UpdateAutoScalingGroupInput{
AutoScalingGroupName: aws.String(d.Id()),
DesiredCapacity: aws.Long(0),
MinSize: aws.Long(0),
MaxSize: aws.Long(0),
DesiredCapacity: aws.Int64(0),
MinSize: aws.Int64(0),
MaxSize: aws.Int64(0),
}
if _, err := conn.UpdateAutoScalingGroup(&opts); err != nil {
return fmt.Errorf("Error setting capacity to zero to drain: %s", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.Group) resourc
t := &autoscaling.TagDescription{
Key: aws.String("Foo"),
Value: aws.String("foo-bar"),
PropagateAtLaunch: aws.Boolean(true),
PropagateAtLaunch: aws.Bool(true),
ResourceType: aws.String("auto-scaling-group"),
ResourceID: group.AutoScalingGroupName,
}
Expand Down
6 changes: 3 additions & 3 deletions builtin/providers/aws/resource_aws_autoscaling_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func getAwsAutoscalingPutScalingPolicyInput(d *schema.ResourceData) autoscaling.
}

if v, ok := d.GetOk("cooldown"); ok {
params.Cooldown = aws.Long(int64(v.(int)))
params.Cooldown = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("scaling_adjustment"); ok {
params.ScalingAdjustment = aws.Long(int64(v.(int)))
params.ScalingAdjustment = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("min_adjustment_step"); ok {
params.MinAdjustmentStep = aws.Long(int64(v.(int)))
params.MinAdjustmentStep = aws.Int64(int64(v.(int)))
}

return params
Expand Down
8 changes: 4 additions & 4 deletions builtin/providers/aws/resource_aws_cloudwatch_metric_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ func getAwsCloudWatchPutMetricAlarmInput(d *schema.ResourceData) cloudwatch.PutM
params := cloudwatch.PutMetricAlarmInput{
AlarmName: aws.String(d.Get("alarm_name").(string)),
ComparisonOperator: aws.String(d.Get("comparison_operator").(string)),
EvaluationPeriods: aws.Long(int64(d.Get("evaluation_periods").(int))),
EvaluationPeriods: aws.Int64(int64(d.Get("evaluation_periods").(int))),
MetricName: aws.String(d.Get("metric_name").(string)),
Namespace: aws.String(d.Get("namespace").(string)),
Period: aws.Long(int64(d.Get("period").(int))),
Period: aws.Int64(int64(d.Get("period").(int))),
Statistic: aws.String(d.Get("statistic").(string)),
Threshold: aws.Double(d.Get("threshold").(float64)),
Threshold: aws.Float64(d.Get("threshold").(float64)),
}

if v := d.Get("actions_enabled"); v != nil {
params.ActionsEnabled = aws.Boolean(v.(bool))
params.ActionsEnabled = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("alarm_description"); ok {
Expand Down
2 changes: 1 addition & 1 deletion builtin/providers/aws/resource_aws_customer_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func resourceAwsCustomerGatewayCreate(d *schema.ResourceData, meta interface{})
conn := meta.(*AWSClient).ec2conn

createOpts := &ec2.CreateCustomerGatewayInput{
BGPASN: aws.Long(int64(d.Get("bgp_asn").(int))),
BGPASN: aws.Int64(int64(d.Get("bgp_asn").(int))),
PublicIP: aws.String(d.Get("ip_address").(string)),
Type: aws.String(d.Get("type").(string)),
}
Expand Down
Loading

0 comments on commit 579ccbe

Please sign in to comment.