Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into datadog_monitor_f…
Browse files Browse the repository at this point in the history
…ull_window

* upstream/master: (31 commits)
  core: Log local overrides as INFO rather than WARN
  provider/aws: Retry resourceAwsLaunchConfigurationCreate if instance profile hasn't propagated (hashicorp#8813)
  changing AWS_SECURITY_TOKEN to AWS_SESSION_TOKEN (hashicorp#8816)
  Update ses_receipt_rule_set.html.markdown
  Warn when plugins are locally overridden
  Fix a typo in the output command examples
  aws_instance doc: fix attachment resource name
  Vendored WAF (hashicorp#8785)
  update github.com/hashicorp/go-getter
  Update CHANGELOG.md
  provider/azurerm: Removing the diagnostics part of the test from the azurerm virtual machine unattended acceptance test
  Update CHANGELOG.md
  Update CHANGELOG.md
  provider/aws: Removal of  test for changes as it forces a new resource
  provider/aws: Allow `aws_alb` to have the name auto-generated
  Update CHANGELOG.md
  Remove Unused Log From CodeCommit Trigger Test
  provider/aws: Support Policy DiffSuppression in `aws_kms_key` policy
  Update CHANGELOG.md
  provider/cloudstack: fix vpc renaming (hashicorp#8784)
  ...
  • Loading branch information
ojongerius committed Sep 14, 2016
2 parents 71fffbd + a0a59d3 commit 5f5cd6f
Show file tree
Hide file tree
Showing 97 changed files with 11,288 additions and 1,932 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
## 0.7.4 (Unreleased)

FEATURES:
* **New Resource:** `aws_codecommit_trigger` [GH-8751]

IMPROVEMENTS:
* provider/aws: Support 'publish' attribute in lambda_function [GH-8653]
* provider/aws: Export AWS ELB service account ARN [GH-8700]
* provider/aws: Allow `aws_alb` to have the name auto-generated [GH-8673]
* provider/azurerm: support Diagnostics Profile [GH-8277]
* provider/google: Resources depending on the `network` attribute can now reference the network by `self_link` or `name` [GH-8639]
* provider/postgresql: The standard environment variables PGHOST, PGUSER, PGPASSWORD and PGSSLMODE are now supported for provider configuration [GH-8666]

BUG FIXES:
* provider/aws: Bump `aws_elasticsearch_domain` timeout values [GH-672]
* provider/aws: `aws_nat_gateways` will now recreate on `failed` state [GH-8689]
* provider/aws: Prevent crash on account ID validation [GH-8731]
* provider/scaleway: fix security_group_rule identification [GH-8661]
* provider/aws: `aws_db_instance` unexpected state when configurating enhanced monitoring [GH-8707]
* provider/aws: Remove region condition from `aws_codecommit_repository` [GH-8778]
* provider/aws: Support Policy DiffSuppression in `aws_kms_key` policy [GH-8675]
* provider/scaleway: Fix `security_group_rule` identification [GH-8661]
* provider/cloudstack: Fix renaming a VPC with the `cloudstack_vpc` resource [GH-8784]

## 0.7.3 (September 5, 2016)

Expand Down
2 changes: 1 addition & 1 deletion builtin/providers/aws/auth_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func TestAWSGetCredentials_shouldBeENV(t *testing.T) {
}
}

// unsetEnv unsets enviornment variables for testing a "clean slate" with no
// unsetEnv unsets environment variables for testing a "clean slate" with no
// credentials in the environment
func unsetEnv(t *testing.T) func() {
// Grab any existing AWS keys and preserve. In some tests we'll unset these, so
Expand Down
3 changes: 3 additions & 0 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/aws/aws-sdk-go/service/waf"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/terraform/helper/logging"
Expand Down Expand Up @@ -133,6 +134,7 @@ type AWSClient struct {
codedeployconn *codedeploy.CodeDeploy
codecommitconn *codecommit.CodeCommit
ssmconn *ssm.SSM
wafconn *waf.WAF
}

// Client configures and returns a fully initialized AWSClient
Expand Down Expand Up @@ -274,6 +276,7 @@ func (c *Config) Client() (interface{}, error) {
client.snsconn = sns.New(sess)
client.sqsconn = sqs.New(sess)
client.ssmconn = ssm.New(sess)
client.wafconn = waf.New(sess)

return &client, nil
}
Expand Down
7 changes: 7 additions & 0 deletions builtin/providers/aws/data_source_aws_elb_service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func dataSourceAwsElbServiceAccount() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand All @@ -44,6 +48,9 @@ func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}

if accid, ok := elbAccountIdPerRegionMap[region]; ok {
d.SetId(accid)

d.Set("arn", "arn:aws:iam::"+accid+":root")

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ func TestAccAWSElbServiceAccount_basic(t *testing.T) {
Config: testAccCheckAwsElbServiceAccountConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "id", "797873946194"),
resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "arn", "arn:aws:iam::797873946194:root"),
),
},
resource.TestStep{
Config: testAccCheckAwsElbServiceAccountExplicitRegionConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "id", "156460612806"),
resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "arn", "arn:aws:iam::156460612806:root"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion builtin/providers/aws/import_aws_kms_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAWSKMSKey_importBasic(t *testing.T) {
func TestAccAWSKmsKey_importBasic(t *testing.T) {
resourceName := "aws_kms_key.foo"

resource.Test(t, resource.TestCase{
Expand Down
5 changes: 3 additions & 2 deletions builtin/providers/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func Provider() terraform.ResourceProvider {
"aws_codedeploy_app": resourceAwsCodeDeployApp(),
"aws_codedeploy_deployment_group": resourceAwsCodeDeployDeploymentGroup(),
"aws_codecommit_repository": resourceAwsCodeCommitRepository(),
"aws_codecommit_trigger": resourceAwsCodeCommitTrigger(),
"aws_customer_gateway": resourceAwsCustomerGateway(),
"aws_db_event_subscription": resourceAwsDbEventSubscription(),
"aws_db_instance": resourceAwsDbInstance(),
Expand Down Expand Up @@ -404,10 +405,10 @@ func init() {

"assume_role_role_arn": "The ARN of an IAM role to assume prior to making API calls.",

"assume_role_session_name": "The session name to use when assuming the role. If ommitted," +
"assume_role_session_name": "The session name to use when assuming the role. If omitted," +
" no session name is passed to the AssumeRole call.",

"assume_role_external_id": "The external ID to use when assuming the role. If ommitted," +
"assume_role_external_id": "The external ID to use when assuming the role. If omitted," +
" no external ID is passed to the AssumeRole call.",
}
}
Expand Down
24 changes: 22 additions & 2 deletions builtin/providers/aws/resource_aws_alb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)

Expand All @@ -28,8 +29,17 @@ func resourceAwsAlb() *schema.Resource {
},

"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"name_prefix"},
ValidateFunc: validateElbName,
},

"name_prefix": {
Type: schema.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validateElbName,
},
Expand Down Expand Up @@ -111,8 +121,18 @@ func resourceAwsAlb() *schema.Resource {
func resourceAwsAlbCreate(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbv2conn

var name string
if v, ok := d.GetOk("name"); ok {
name = v.(string)
} else if v, ok := d.GetOk("name_prefix"); ok {
name = resource.PrefixedUniqueId(v.(string))
} else {
name = resource.PrefixedUniqueId("tf-lb-")
}
d.Set("name", name)

elbOpts := &elbv2.CreateLoadBalancerInput{
Name: aws.String(d.Get("name").(string)),
Name: aws.String(name),
Tags: tagsFromMapELBv2(d.Get("tags").(map[string]interface{})),
}

Expand Down
178 changes: 178 additions & 0 deletions builtin/providers/aws/resource_aws_alb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"errors"
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -45,6 +46,48 @@ func TestAccAWSALB_basic(t *testing.T) {
})
}

func TestAccAWSALB_generatedName(t *testing.T) {
var conf elbv2.LoadBalancer

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_alb.alb_test",
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSALBDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSALBConfig_generatedName(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSALBExists("aws_alb.alb_test", &conf),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "name"),
),
},
},
})
}

func TestAccAWSALB_namePrefix(t *testing.T) {
var conf elbv2.LoadBalancer

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_alb.alb_test",
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSALBDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSALBConfig_namePrefix(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSALBExists("aws_alb.alb_test", &conf),
resource.TestCheckResourceAttrSet("aws_alb.alb_test", "name"),
resource.TestMatchResourceAttr("aws_alb.alb_test", "name",
regexp.MustCompile("^tf-lb")),
),
},
},
})
}

func TestAccAWSALB_tags(t *testing.T) {
var conf elbv2.LoadBalancer
albName := fmt.Sprintf("testaccawsalb-basic-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
Expand Down Expand Up @@ -292,6 +335,141 @@ resource "aws_security_group" "alb_test" {
}
}`, albName)
}

func testAccAWSALBConfig_generatedName() string {
return fmt.Sprintf(`
resource "aws_alb" "alb_test" {
internal = false
security_groups = ["${aws_security_group.alb_test.id}"]
subnets = ["${aws_subnet.alb_test.*.id}"]
idle_timeout = 30
enable_deletion_protection = false
tags {
TestName = "TestAccAWSALB_basic"
}
}
variable "subnets" {
default = ["10.0.1.0/24", "10.0.2.0/24"]
type = "list"
}
data "aws_availability_zones" "available" {}
resource "aws_vpc" "alb_test" {
cidr_block = "10.0.0.0/16"
tags {
TestName = "TestAccAWSALB_basic"
}
}
resource "aws_subnet" "alb_test" {
count = 2
vpc_id = "${aws_vpc.alb_test.id}"
cidr_block = "${element(var.subnets, count.index)}"
map_public_ip_on_launch = true
availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}"
tags {
TestName = "TestAccAWSALB_basic"
}
}
resource "aws_security_group" "alb_test" {
name = "allow_all_alb_test"
description = "Used for ALB Testing"
vpc_id = "${aws_vpc.alb_test.id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
TestName = "TestAccAWSALB_basic"
}
}`)
}

func testAccAWSALBConfig_namePrefix() string {
return fmt.Sprintf(`
resource "aws_alb" "alb_test" {
name_prefix = "tf-lb"
internal = false
security_groups = ["${aws_security_group.alb_test.id}"]
subnets = ["${aws_subnet.alb_test.*.id}"]
idle_timeout = 30
enable_deletion_protection = false
tags {
TestName = "TestAccAWSALB_basic"
}
}
variable "subnets" {
default = ["10.0.1.0/24", "10.0.2.0/24"]
type = "list"
}
data "aws_availability_zones" "available" {}
resource "aws_vpc" "alb_test" {
cidr_block = "10.0.0.0/16"
tags {
TestName = "TestAccAWSALB_basic"
}
}
resource "aws_subnet" "alb_test" {
count = 2
vpc_id = "${aws_vpc.alb_test.id}"
cidr_block = "${element(var.subnets, count.index)}"
map_public_ip_on_launch = true
availability_zone = "${element(data.aws_availability_zones.available.names, count.index)}"
tags {
TestName = "TestAccAWSALB_basic"
}
}
resource "aws_security_group" "alb_test" {
name = "allow_all_alb_test"
description = "Used for ALB Testing"
vpc_id = "${aws_vpc.alb_test.id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
TestName = "TestAccAWSALB_basic"
}
}`)
}
func testAccAWSALBConfig_updatedTags(albName string) string {
return fmt.Sprintf(`resource "aws_alb" "alb_test" {
name = "%s"
Expand Down
2 changes: 1 addition & 1 deletion builtin/providers/aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{})
if v, ok := d.GetOk("termination_policies"); ok && len(v.([]interface{})) > 0 {
opts.TerminationPolicies = expandStringList(v.([]interface{}))
} else {
log.Printf("[DEBUG] Explictly setting null termination policy to 'Default'")
log.Printf("[DEBUG] Explicitly setting null termination policy to 'Default'")
opts.TerminationPolicies = aws.StringSlice([]string{"Default"})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func resourceAwsCloudFrontDistributionDelete(d *schema.ResourceData, meta interf

// skip delete if retain_on_delete is enabled
if d.Get("retain_on_delete").(bool) {
log.Printf("[WARN] Removing Distribtuion ID %s with retain_on_delete set. Please delete this distribution manually.", d.Id())
log.Printf("[WARN] Removing Distributions ID %s with retain_on_delete set. Please delete this distribution manually.", d.Id())
d.SetId("")
return nil
}
Expand Down
Loading

0 comments on commit 5f5cd6f

Please sign in to comment.