Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable-website' into fix-impor…
Browse files Browse the repository at this point in the history
…ted-certificates-update
  • Loading branch information
jocgir committed Oct 22, 2019
2 parents e7a2516 + 73c1eb5 commit 21dd050
Show file tree
Hide file tree
Showing 3,107 changed files with 71,554 additions and 36,770 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
103 changes: 102 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ability to merge PRs and respond to issues.
- [Running an Acceptance Test](#running-an-acceptance-test)
- [Writing an Acceptance Test](#writing-an-acceptance-test)
- [Writing and running Cross-Account Acceptance Tests](#writing-and-running-cross-account-acceptance-tests)
- [Writing and running Cross-Region Acceptance Tests](#writing-and-running-cross-region-acceptance-tests)

<!-- /TOC -->

Expand Down Expand Up @@ -290,6 +291,35 @@ into Terraform.
`quicksightconn: quicksight.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["quicksight"])})),`
- In `website/docs/guides/custom-service-endpoints.html.md`: Add the service
name in the list of customizable endpoints.
- In `.hashibot.hcl`: Add the new service to automated issue and pull request labeling. e.g. with the `quicksight` service

```hcl
behavior "regexp_issue_labeler_v2" "service_labels" {
# ... other configuration ...
label_map = {
# ... other services ...
"service/quicksight" = [
"aws_quicksight_",
],
# ... other services ...
}
}
behavior "pull_request_path_labeler" "service_labels"
# ... other configuration ...
label_map = {
# ... other services ...
"service/quicksight" = [
"**/*_quicksight_*",
"**/quicksight_*",
],
# ... other services ...
}
}
```

- Run the following then submit the pull request:

```sh
Expand Down Expand Up @@ -448,7 +478,7 @@ The below are location-based items that _may_ be noted during review and are rec
```
- [ ] __Uses aws_availability_zones Data Source__: Any hardcoded AWS Availability Zone configuration, e.g. `us-west-2a`, should be replaced with the [`aws_availability_zones` data source](https://www.terraform.io/docs/providers/aws/d/availability_zones.html). A common pattern is declaring `data "aws_availability_zones" "current" {}` and referencing it via `data.aws_availability_zones.current.names[0]` or `data.aws_availability_zones.current.names[count.index]` in resources utilizing `count`.
- [ ] __Uses aws_region Data Source__: Any hardcoded AWS Region configuration, e.g. `us-west-2`, should be replaced with the [`aws_region` data source](https://www.terraform.io/docs/providers/aws/d/region.html). A common pattern is declaring `data "aws_region" "cname}` and referencing it via `data.aws_region.current.name`
- [ ] __Uses aws_region Data Source__: Any hardcoded AWS Region configuration, e.g. `us-west-2`, should be replaced with the [`aws_region` data source](https://www.terraform.io/docs/providers/aws/d/region.html). A common pattern is declaring `data "aws_region" "current" {}` and referencing it via `data.aws_region.current.name`
- [ ] __Uses aws_partition Data Source__: Any hardcoded AWS Partition configuration, e.g. the `aws` in a `arn:aws:SERVICE:REGION:ACCOUNT:RESOURCE` ARN, should be replaced with the [`aws_partition` data source](https://www.terraform.io/docs/providers/aws/d/partition.html). A common pattern is declaring `data "aws_partition" "current" {}` and referencing it via `data.aws_partition.current.partition`
- [ ] __Uses Builtin ARN Check Functions__: Tests should utilize available ARN check functions, e.g. `testAccMatchResourceAttrRegionalARN()`, to validate ARN attribute values in the Terraform state over `resource.TestCheckResourceAttrSet()` and `resource.TestMatchResourceAttr()`
- [ ] __Uses testAccCheckResourceAttrAccountID()__: Tests should utilize the available AWS Account ID check function, `testAccCheckResourceAttrAccountID()` to validate account ID attribute values in the Terraform state over `resource.TestCheckResourceAttrSet()` and `resource.TestMatchResourceAttr()`
Expand Down Expand Up @@ -748,6 +778,77 @@ export AWS_ALTERNATE_ACCESS_KEY_ID=...
export AWS_ALTERNATE_SECRET_ACCESS_KEY=...
```
#### Writing and running Cross-Region Acceptance Tests
When testing requires AWS infrastructure in a second AWS region, the below changes to the normal setup will allow the management or reference of resources and data sources across regions:
- In the `PreCheck` function, include `testAccMultipleRegionsPreCheck(t)` and `testAccAlternateRegionPreCheck(t)` to ensure a standardized set of information is required for cross-region testing configuration. If the infrastructure in the second AWS region is also in a second AWS account also include `testAccAlternateAccountPreCheck(t)`
- Declare a `providers` variable at the top of the test function: `var providers []*schema.Provider`
- Switch usage of `Providers: testAccProviders` to `ProviderFactories: testAccProviderFactories(&providers)`
- Add `testAccAlternateRegionProviderConfig()` to the test configuration and use `provider = "aws.alternate"` for cross-region resources. The resource that is the focus of the acceptance test should _not_ use the provider alias to simplify the testing setup. If the infrastructure in the second AWS region is also in a second AWS account use `testAccAlternateAccountAlternateRegionProviderConfig()` instead
- For any `TestStep` that includes `ImportState: true`, add the `Config` that matches the previous `TestStep` `Config`
An example acceptance test implementation can be seen below:
```go
func TestAccAwsExample_basic(t *testing.T) {
var providers []*schema.Provider
resourceName := "aws_example.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccMultipleRegionsPreCheck(t)
testAccAlternateRegionPreCheck(t)
},
ProviderFactories: testAccProviderFactories(&providers),
CheckDestroy: testAccCheckAwsExampleDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsExampleConfig(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsExampleExists(resourceName),
// ... additional checks ...
),
},
{
Config: testAccAwsExampleConfig(),
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccAwsExampleConfig() string {
return testAccAlternateRegionProviderConfig() + fmt.Sprintf(`
# Cross region resources should be handled by the cross region provider.
# The standardized provider alias is aws.alternate as seen below.
resource "aws_cross_region_example" "test" {
provider = "aws.alternate"
# ... configuration ...
}
# The resource that is the focus of the testing should be handled by the default provider,
# which is automatically done by not specifying the provider configuration in the resource.
resource "aws_example" "test" {
# ... configuration ...
}
`)
}
```
Searching for usage of `testAccAlternateRegionPreCheck` in the codebase will yield real world examples of this setup in action.
Running these acceptance tests is the same as before, except if an AWS region other than the default alternate region - `us-east-1` - is required,
in which case the following additional configuration information is required:
```sh
export AWS_ALTERNATE_REGION=...
```
[website]: https://github.com/terraform-providers/terraform-provider-aws/tree/master/website
[acctests]: https://github.com/hashicorp/terraform#acceptance-tests
[ml]: https://groups.google.com/group/terraform-tool
51 changes: 0 additions & 51 deletions .github/PULL_REQUEST_LABELS.yml

This file was deleted.

14 changes: 11 additions & 3 deletions .github/workflows/issues.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
on: issues
name: Issue triage
jobs:
applyTriageLabel:
name: Apply Triage Label
markIssuesForTriage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1.0.0
- uses: actions/github@v1.0.0
- name: Apply Triage Label
uses: actions/github@v1.0.0
if: github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: label needs-triage

- name: Add new issue into Triage Board
uses: alex-page/github-project-automation-plus@v0.1.1
if: github.event.action == 'opened'
with:
project: AWS Provider Triage
column: Needs Triage
repo-token: ${{ secrets.GITHUB_ACTIONS_TOKEN }}
12 changes: 0 additions & 12 deletions .github/workflows/pull_request.yml

This file was deleted.

12 changes: 8 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
issues:
exclude-rules:
# Exclude issues bypassing staticcheck.conf
- linters:
- staticcheck
text: "SA1019:"
max-per-linter: 0
max-same-issues: 0

Expand All @@ -11,8 +16,7 @@ linters:
- gosimple
- ineffassign
- misspell
# Run separately for TravisCI memory issues
# - staticcheck
- staticcheck
- structcheck
- unconvert
- unused
Expand All @@ -21,8 +25,8 @@ linters:

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform/helper/schema:ForceNew|Set,fmt:.*,io:Close
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close

run:
deadline: 5m
modules-download-mode: vendor
timeout: 10m
Loading

0 comments on commit 21dd050

Please sign in to comment.