Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable-website' into support-m…
Browse files Browse the repository at this point in the history
…etadata-on-s3-objects
  • Loading branch information
jocgir committed May 20, 2019
2 parents 0db5475 + 49b58fa commit a3931ef
Show file tree
Hide file tree
Showing 408 changed files with 76,369 additions and 9,873 deletions.
213 changes: 128 additions & 85 deletions .github/CONTRIBUTING.md

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

Fixes #0000

Changes proposed in this pull request:
Release note for [CHANGELOG](https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md):
<!--
If change is not user facing, just write "NONE" in the release-note block below.
-->

* Change 1
* Change 2
```release-note
```

Output from acceptance testing:

Expand Down
121 changes: 105 additions & 16 deletions CHANGELOG.md

Large diffs are not rendered by default.

38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,27 @@ Requirements
- [Terraform](https://www.terraform.io/downloads.html) 0.10+
- [Go](https://golang.org/doc/install) 1.12 (to build the provider plugin)

Building the Provider
Developing the Provider
---------------------

Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-aws`
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (please check the [requirements](https://github.com/terraform-providers/terraform-provider-aws#requirements) before proceeding).

*Note:* This project uses [Go Modules](https://blog.golang.org/using-go-modules) making it safe to work with it outside of your existing [GOPATH](http://golang.org/doc/code.html#GOPATH). The instructions that follow assume a directory in your home directory outside of the standard GOPATH (i.e `$HOME/development/terraform-providers/`).

Clone repository to: `$HOME/development/terraform-providers/`

```sh
$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ mkdir -p $HOME/development/terraform-providers/; cd $HOME/development/terraform-providers/
$ git clone git@github.com:terraform-providers/terraform-provider-aws
...
```

Enter the provider directory and build the provider
Enter the provider directory and run `make tools`. This will install the needed tools for the provider.

```sh
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-aws
$ make build
$ make tools
```

Using the Provider
----------------------
If you're building the provider, follow the instructions to [install it as a plugin.](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin) After placing it into your plugins directory, run `terraform init` to initialize it. Documentation about the provider specific configuration options can be found on the [provider's website](https://www.terraform.io/docs/providers/aws/index.html).

Developing the Provider
---------------------------

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.12+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.

To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

```sh
Expand All @@ -48,10 +43,19 @@ $ $GOPATH/bin/terraform-provider-aws
...
```

Using the Provider
----------------------

To use a released provider in your Terraform environment, run [`terraform init`](https://www.terraform.io/docs/commands/init.html) and Terraform will automatically install the provider. To specify a particular provider version when installing released providers, see the [Terraform documentation on provider versioning](https://www.terraform.io/docs/configuration/providers.html#version-provider-versions).

To instead use a custom-built provider in your Terraform environment (e.g. the provider binary from the build instructions above), follow the instructions to [install it as a plugin.](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin) After placing it into your plugins directory, run `terraform init` to initialize it.

For either installation method, documentation about the provider specific configuration options can be found on the [provider's website](https://www.terraform.io/docs/providers/aws/index.html).

Testing the Provider
---------------------------

In order to test the provider, you can simply run `make test`.
In order to test the provider, you can run `make test`.

*Note:* Make sure no `AWS_ACCESS_KEY_ID` or `AWS_SECRET_ACCESS_KEY` variables are set, and there's no `[default]` section in the AWS credentials file `~/.aws/credentials`.

Expand All @@ -61,7 +65,7 @@ $ make test

In order to run the full suite of Acceptance tests, run `make testacc`.

*Note:* Acceptance tests create real resources, and often cost money to run.
*Note:* Acceptance tests create real resources, and often cost money to run. Please read [Running an Acceptance Test](https://github.com/terraform-providers/terraform-provider-aws/blob/master/.github/CONTRIBUTING.md#running-an-acceptance-test) in the contribution guidelines for more information on usage.

```sh
$ make testacc
Expand Down
2 changes: 1 addition & 1 deletion aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func expandForwardedValues(m map[string]interface{}) *cloudfront.ForwardedValues
fv := &cloudfront.ForwardedValues{
QueryString: aws.Bool(m["query_string"].(bool)),
}
if v, ok := m["cookies"]; ok && len(v.([]interface{})) > 0 {
if v, ok := m["cookies"]; ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
fv.Cookies = expandCookiePreference(v.([]interface{})[0].(map[string]interface{}))
}
if v, ok := m["headers"]; ok {
Expand Down
10 changes: 8 additions & 2 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import (
"github.com/aws/aws-sdk-go/service/licensemanager"
"github.com/aws/aws-sdk-go/service/lightsail"
"github.com/aws/aws-sdk-go/service/macie"
"github.com/aws/aws-sdk-go/service/managedblockchain"
"github.com/aws/aws-sdk-go/service/mediaconnect"
"github.com/aws/aws-sdk-go/service/mediaconvert"
"github.com/aws/aws-sdk-go/service/medialive"
Expand Down Expand Up @@ -123,6 +124,7 @@ import (
"github.com/aws/aws-sdk-go/service/wafregional"
"github.com/aws/aws-sdk-go/service/worklink"
"github.com/aws/aws-sdk-go/service/workspaces"
"github.com/aws/aws-sdk-go/service/xray"
awsbase "github.com/hashicorp/aws-sdk-go-base"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/terraform"
Expand Down Expand Up @@ -231,6 +233,7 @@ type AWSClient struct {
licensemanagerconn *licensemanager.LicenseManager
lightsailconn *lightsail.Lightsail
macieconn *macie.Macie
managedblockchainconn *managedblockchain.ManagedBlockchain
mediaconnectconn *mediaconnect.MediaConnect
mediaconvertconn *mediaconvert.MediaConvert
medialiveconn *medialive.MediaLive
Expand Down Expand Up @@ -276,6 +279,7 @@ type AWSClient struct {
wafregionalconn *wafregional.WAFRegional
worklinkconn *worklink.WorkLink
workspacesconn *workspaces.WorkSpaces
xrayconn *xray.XRay
}

// Client configures and returns a fully initialized AWSClient
Expand Down Expand Up @@ -386,7 +390,7 @@ func (c *Config) Client() (interface{}, error) {
fsxconn: fsx.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["fsx"])})),
gameliftconn: gamelift.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["gamelift"])})),
glacierconn: glacier.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["glacier"])})),
globalacceleratorconn: globalaccelerator.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["globalaccelerator"])})),
globalacceleratorconn: globalaccelerator.New(sess.Copy(&aws.Config{Region: aws.String("us-west-2"), Endpoint: aws.String(c.Endpoints["globalaccelerator"])})),
glueconn: glue.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["glue"])})),
guarddutyconn: guardduty.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["guardduty"])})),
iamconn: iam.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["iam"])})),
Expand All @@ -403,6 +407,7 @@ func (c *Config) Client() (interface{}, error) {
licensemanagerconn: licensemanager.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["licensemanager"])})),
lightsailconn: lightsail.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["lightsail"])})),
macieconn: macie.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["macie"])})),
managedblockchainconn: managedblockchain.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["managedblockchain"])})),
mediaconnectconn: mediaconnect.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediaconnect"])})),
mediaconvertconn: mediaconvert.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediaconvert"])})),
medialiveconn: medialive.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["medialive"])})),
Expand Down Expand Up @@ -434,7 +439,7 @@ func (c *Config) Client() (interface{}, error) {
serverlessapplicationrepositoryconn: serverlessapplicationrepository.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["serverlessrepo"])})),
sesConn: ses.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ses"])})),
sfnconn: sfn.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["stepfunctions"])})),
shieldconn: shield.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["shield"])})),
shieldconn: shield.New(sess.Copy(&aws.Config{Region: aws.String("us-east-1"), Endpoint: aws.String(c.Endpoints["shield"])})),
simpledbconn: simpledb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sdb"])})),
snsconn: sns.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sns"])})),
sqsconn: sqs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sqs"])})),
Expand All @@ -447,6 +452,7 @@ func (c *Config) Client() (interface{}, error) {
wafregionalconn: wafregional.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["wafregional"])})),
worklinkconn: worklink.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["worklink"])})),
workspacesconn: workspaces.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["workspaces"])})),
xrayconn: xray.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["xray"])})),
}

// Handle deprecated endpoint configurations
Expand Down
27 changes: 25 additions & 2 deletions aws/data_source_aws_availability_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ func dataSourceAwsAvailabilityZones() *schema.Resource {
Read: dataSourceAwsAvailabilityZonesRead,

Schema: map[string]*schema.Schema{
"blacklisted_names": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"blacklisted_zone_ids": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"names": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -68,11 +78,24 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{}
return aws.StringValue(resp.AvailabilityZones[i].ZoneName) < aws.StringValue(resp.AvailabilityZones[j].ZoneName)
})

blacklistedNames := d.Get("blacklisted_names").(*schema.Set)
blacklistedZoneIDs := d.Get("blacklisted_zone_ids").(*schema.Set)
names := []string{}
zoneIds := []string{}
for _, v := range resp.AvailabilityZones {
names = append(names, aws.StringValue(v.ZoneName))
zoneIds = append(zoneIds, aws.StringValue(v.ZoneId))
name := aws.StringValue(v.ZoneName)
zoneID := aws.StringValue(v.ZoneId)

if blacklistedNames.Contains(name) {
continue
}

if blacklistedZoneIDs.Contains(zoneID) {
continue
}

names = append(names, name)
zoneIds = append(zoneIds, zoneID)
}

if err := d.Set("names", names); err != nil {
Expand Down
90 changes: 90 additions & 0 deletions aws/data_source_aws_availability_zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,42 @@ func TestAccAWSAvailabilityZones_basic(t *testing.T) {
})
}

func TestAccAWSAvailabilityZones_BlacklistedNames(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
blacklistedDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedNames(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName),
),
},
},
})
}

func TestAccAWSAvailabilityZones_BlacklistedZoneIds(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
blacklistedDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedZoneIds(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName),
),
},
},
})
}

func TestAccAWSAvailabilityZones_stateFilter(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -128,6 +164,40 @@ func testAccCheckAwsAvailabilityZonesMeta(n string) resource.TestCheckFunc {
}
}

func testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
allResourceState, ok := s.RootModule().Resources[allDataSourceName]
if !ok {
return fmt.Errorf("Resource does not exist: %s", allDataSourceName)
}

blacklistedResourceState, ok := s.RootModule().Resources[blacklistedDataSourceName]
if !ok {
return fmt.Errorf("Resource does not exist: %s", blacklistedDataSourceName)
}

for _, attribute := range []string{"names.#", "zone_ids.#"} {
allValue, ok := allResourceState.Primary.Attributes[attribute]

if !ok {
return fmt.Errorf("cannot find %s in %s resource state attributes: %+v", attribute, allDataSourceName, allResourceState.Primary.Attributes)
}

blacklistedValue, ok := blacklistedResourceState.Primary.Attributes[attribute]

if !ok {
return fmt.Errorf("cannot find %s in %s resource state attributes: %+v", attribute, blacklistedDataSourceName, blacklistedResourceState.Primary.Attributes)
}

if allValue == blacklistedValue {
return fmt.Errorf("expected %s attribute value difference, got: %s", attribute, allValue)
}
}

return nil
}
}

func testAccCheckAwsAvailabilityZoneState(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -179,6 +249,26 @@ const testAccCheckAwsAvailabilityZonesConfig = `
data "aws_availability_zones" "availability_zones" { }
`

func testAccCheckAwsAvailabilityZonesConfigBlacklistedNames() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}
data "aws_availability_zones" "test" {
blacklisted_names = ["${data.aws_availability_zones.all.names[0]}"]
}
`)
}

func testAccCheckAwsAvailabilityZonesConfigBlacklistedZoneIds() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}
data "aws_availability_zones" "test" {
blacklisted_zone_ids = ["${data.aws_availability_zones.all.zone_ids[0]}"]
}
`)
}

const testAccCheckAwsAvailabilityZonesStateConfig = `
data "aws_availability_zones" "state_filter" {
state = "available"
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_cloudtrail_service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// See https://docs.aws.amazon.com/govcloud-us/latest/ug-east/verifying-cloudtrail.html
// See https://docs.aws.amazon.com/govcloud-us/latest/ug-west/verifying-cloudtrail.html
var cloudTrailServiceAccountPerRegionMap = map[string]string{
"ap-east-1": "119688915426",
"ap-northeast-1": "216624486486",
"ap-northeast-2": "492519147666",
"ap-northeast-3": "765225791966",
Expand Down
6 changes: 6 additions & 0 deletions aws/data_source_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ func dataSourceAwsDbInstance() *schema.Resource {
Computed: true,
},

"resource_id": {
Type: schema.TypeString,
Computed: true,
},

"storage_encrypted": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -241,6 +246,7 @@ func dataSourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error
d.Set("db_instance_arn", dbInstance.DBInstanceArn)
d.Set("db_instance_class", dbInstance.DBInstanceClass)
d.Set("db_name", dbInstance.DBName)
d.Set("resource_id", dbInstance.DbiResourceId)

var parameterGroups []string
for _, v := range dbInstance.DBParameterGroups {
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccAWSDbInstanceDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.aws_db_instance.bar", "port"),
resource.TestCheckResourceAttrSet("data.aws_db_instance.bar", "enabled_cloudwatch_logs_exports.0"),
resource.TestCheckResourceAttrSet("data.aws_db_instance.bar", "enabled_cloudwatch_logs_exports.1"),
resource.TestCheckResourceAttrPair("data.aws_db_instance.bar", "resource_id", "aws_db_instance.bar", "resource_id"),
),
},
},
Expand Down
Loading

0 comments on commit a3931ef

Please sign in to comment.