Skip to content

Commit bbfb03c

Browse files
authored
Merge pull request #6 from sterliakov/bugfix/st-force-virginia-for-token
fix: Require two separate provider configurations
2 parents b18b8b7 + 8ee8570 commit bbfb03c

File tree

8 files changed

+49
-15
lines changed

8 files changed

+49
-15
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
GITHUB_TOKEN: ${{ github.token }}
4444

4545
- uses: pre-commit/[email protected]
46-
with:
47-
extra_args: --all-files --show-diff-on-failure
4846

4947
test:
5048
name: Test

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ repos:
2828
args: [-x, -P, SCRIPTDIR, -S, style]
2929

3030
- repo: https://github.com/antonbabenko/pre-commit-terraform
31-
rev: v1.96.1
31+
rev: v1.97.4
3232
hooks:
33-
- id: terraform_validate
3433
- id: terraform_fmt
3534
- id: terraform_tflint
3635
- id: terraform_docs
3736
args:
3837
- --hook-config=--config-file=.terraform-docs.yml
3938

4039
- repo: https://github.com/bridgecrewio/checkov.git
41-
rev: 3.2.277
40+
rev: 3.2.382
4241
hooks:
4342
- id: checkov
4443
args:
@@ -52,3 +51,8 @@ repos:
5251
- examples/
5352
- --skip-path
5453
- tests/
54+
55+
- repo: https://github.com/codespell-project/codespell
56+
rev: v2.4.1
57+
hooks:
58+
- id: codespell

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ representative at an online or offline event.
5858

5959
## Enforcement
6060

61-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62-
reported to the community leaders responsible for enforcement at
63-
6461
All complaints will be reviewed and investigated promptly and fairly.
6562

6663
All community leaders are obligated to respect the privacy and security of the

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ but the implementation was significantly rewritten.
2929
Push a dummy Alpine image to a newly created ECR repository:
3030

3131
```terraform
32+
provider "aws" {
33+
region = "us-east-2"
34+
}
35+
provider "aws" {
36+
region = "us-east-1"
37+
alias = "aws.virginia"
38+
}
39+
3240
resource "aws_ecr_repository" "example" {
3341
name = "example"
3442
}
3543
3644
module "ecr_repo_image" {
3745
source = "sterliakov/ecr-image/aws"
38-
version = "0.1.0"
46+
version = "0.2.0"
47+
providers = {
48+
aws.main = aws
49+
aws.virginia = aws.virginia
50+
}
3951
4052
push_ecr_is_public = false
4153
push_repo_fqdn = replace(aws_ecr_repository.example.repository_url, "//.*$/", "") # remove everything after first slash
@@ -46,6 +58,9 @@ module "ecr_repo_image" {
4658

4759
## NOTES
4860

61+
* This module needs two provider aliases: `aws.main` and `aws.virginia`. They
62+
may refer to the same provider. `aws.virginia` must be in `us-east-1` region.
63+
`aws.main` should be the provider for region where your repository is located.
4964
* This module only works under Linux.
5065
* Destroying this module does not remove the pushed image from the repository. Consider
5166
setting `force_delete = True` on the `aws_ecr_repository` resource if you
@@ -88,7 +103,8 @@ No outputs.
88103

89104
| Name | Version |
90105
|------|---------|
91-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.40.0 |
106+
| <a name="provider_aws.main"></a> [aws.main](#provider\_aws.main) | >= 5.40.0 |
107+
| <a name="provider_aws.virginia"></a> [aws.virginia](#provider\_aws.virginia) | >= 5.40.0 |
92108
| <a name="provider_terraform"></a> [terraform](#provider\_terraform) | n/a |
93109

94110
## Requirements

examples/lambda/ecr.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ resource "aws_ecr_repository" "example" {
55

66
module "ecr_repo_image" {
77
source = "sterliakov/ecr-image/aws"
8-
version = "0.1.0"
8+
version = "0.2.0"
9+
providers = {
10+
aws.main = aws
11+
aws.virginia = aws
12+
}
913

1014
push_ecr_is_public = false
1115
push_repo_fqdn = replace(aws_ecr_repository.example.repository_url, "//.*$/", "") # remove everything after first slash

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
data "aws_ecrpublic_authorization_token" "token" {}
2-
data "aws_ecr_authorization_token" "token" {}
1+
data "aws_ecrpublic_authorization_token" "token" {
2+
provider = aws.virginia
3+
}
4+
data "aws_ecr_authorization_token" "token" {
5+
provider = aws.main
6+
}
37

48
locals {
59
pull_then_push_path = "${path.module}/scripts/pull_then_push.sh"

tests/simple.tftest.hcl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ run "setup" {
1313
}
1414

1515
run "execute" {
16+
providers = {
17+
aws.main = aws
18+
aws.virginia = aws
19+
}
20+
1621
variables {
1722
push_repo_fqdn = replace(run.setup.repo_url, "//.*$/", "") # remove everything after first slash
1823
push_repo_name = run.setup.repo_name
@@ -31,6 +36,11 @@ run "verify" {
3136
}
3237

3338
run "execute_again" {
39+
providers = {
40+
aws.main = aws
41+
aws.virginia = aws
42+
}
43+
3444
# Ensure no drift
3545
variables {
3646
push_repo_fqdn = replace(run.setup.repo_url, "//.*$/", "") # remove everything after first slash

versions.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ terraform {
33

44
required_providers {
55
aws = {
6-
source = "hashicorp/aws"
7-
version = ">= 5.40.0"
6+
source = "hashicorp/aws"
7+
version = ">= 5.40.0"
8+
configuration_aliases = [aws.main, aws.virginia]
89
}
910
}
1011
}

0 commit comments

Comments
 (0)