Skip to content

Commit db33b50

Browse files
committed
upgrade dependencies
1 parent c2a5113 commit db33b50

File tree

15 files changed

+259
-206
lines changed

15 files changed

+259
-206
lines changed

.github/workflows/lint.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ jobs:
55
name: fmt check
66
runs-on: ubuntu-22.04
77
steps:
8-
- uses: actions/checkout@v4
8+
- uses: actions/checkout@v5
99
- uses: hashicorp/setup-terraform@v3
1010
with:
1111
# renovate: datasource=github-releases depName=hashicorp/terraform
12-
terraform_version: "1.8.2"
12+
terraform_version: "1.13.2"
1313
- name: terraform fmt check
1414
run: terraform fmt -check -diff
1515
validate:
1616
name: validate
1717
runs-on: ubuntu-22.04
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
- uses: hashicorp/setup-terraform@v3
2121
with:
2222
# renovate: datasource=github-releases depName=hashicorp/terraform
23-
terraform_version: "1.8.2"
23+
terraform_version: "1.13.2"
2424
- name: Init
2525
run: terraform init -lockfile=readonly
2626
- name: Validate
@@ -29,16 +29,16 @@ jobs:
2929
name: Lint
3030
runs-on: ubuntu-22.04
3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
3333
- uses: hashicorp/setup-terraform@v3
3434
with:
3535
# renovate: datasource=github-releases depName=hashicorp/terraform
36-
terraform_version: "1.8.2"
37-
- uses: terraform-linters/setup-tflint@v4
36+
terraform_version: "1.13.2"
37+
- uses: terraform-linters/setup-tflint@v5
3838
name: Setup
3939
with:
4040
# renovate: datasource=github-releases depName=terraform-linters/tflint
41-
tflint_version: v0.51.0
41+
tflint_version: v0.59.1
4242
- name: Init
4343
run: tflint --init
4444
env:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tmp/
22
.terraform/
33
terraform.tfstate*
44
terraform-graph.svg
5-
secrets.*
5+
secrets*
66
*.tmp.png
77
*.log
88
example/example

.terraform.lock.hcl

Lines changed: 86 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cSpell.words": [
33
"bson",
4+
"DOCDB",
45
"Upsert"
56
]
67
}

README.md

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,90 @@ Install the dependencies:
3131
* [Terraform](https://www.terraform.io/downloads.html).
3232
* [Docker](https://docs.docker.com/engine/install/).
3333

34-
Set the AWS Account credentials using SSO:
34+
Set the AWS Account credentials using SSO, e.g.:
3535

3636
```bash
37+
# set the account credentials.
38+
# NB the aws cli stores these at ~/.aws/config.
39+
# NB this is equivalent to manually configuring SSO using aws configure sso.
40+
# see https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html#sso-configure-profile-token-manual
41+
# see https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html#sso-configure-profile-token-auto-sso
42+
cat >secrets.sh <<'EOF'
3743
# set the environment variables to use a specific profile.
38-
# e.g. use the pattern <aws-sso-session-name>-<aws-account-name>-<aws-account-role>-<aws-account-id>
39-
export AWS_PROFILE=example-dev-AdministratorAccess-123456
44+
# NB use aws configure sso to configure these manually.
45+
# e.g. use the pattern <aws-sso-session>-<aws-account-id>-<aws-role-name>
46+
export aws_sso_session='example'
47+
export aws_sso_start_url='https://example.awsapps.com/start'
48+
export aws_sso_region='eu-west-1'
49+
export aws_sso_account_id='123456'
50+
export aws_sso_role_name='AdministratorAccess'
51+
export AWS_PROFILE="$aws_sso_session-$aws_sso_account_id-$aws_sso_role_name"
4052
unset AWS_ACCESS_KEY_ID
4153
unset AWS_SECRET_ACCESS_KEY
4254
unset AWS_DEFAULT_REGION
43-
# set the account credentials.
44-
# see https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html#sso-configure-profile-token-auto-sso
45-
aws configure sso
46-
# dump the configured profile and sso-session.
47-
cat ~/.aws/config
55+
# configure the ~/.aws/config file.
56+
# NB unfortunately, I did not find a way to create the [sso-session] section
57+
# inside the ~/.aws/config file using the aws cli. so, instead, manage that
58+
# file using python.
59+
python3 <<'PY_EOF'
60+
import configparser
61+
import os
62+
aws_sso_session = os.getenv('aws_sso_session')
63+
aws_sso_start_url = os.getenv('aws_sso_start_url')
64+
aws_sso_region = os.getenv('aws_sso_region')
65+
aws_sso_account_id = os.getenv('aws_sso_account_id')
66+
aws_sso_role_name = os.getenv('aws_sso_role_name')
67+
aws_profile = os.getenv('AWS_PROFILE')
68+
config = configparser.ConfigParser()
69+
aws_config_directory_path = os.path.expanduser('~/.aws')
70+
aws_config_path = os.path.join(aws_config_directory_path, 'config')
71+
if os.path.exists(aws_config_path):
72+
config.read(aws_config_path)
73+
config[f'sso-session {aws_sso_session}'] = {
74+
'sso_start_url': aws_sso_start_url,
75+
'sso_region': aws_sso_region,
76+
'sso_registration_scopes': 'sso:account:access',
77+
}
78+
config[f'profile {aws_profile}'] = {
79+
'sso_session': aws_sso_session,
80+
'sso_account_id': aws_sso_account_id,
81+
'sso_role_name': aws_sso_role_name,
82+
'region': aws_sso_region,
83+
}
84+
os.makedirs(aws_config_directory_path, mode=0o700, exist_ok=True)
85+
with open(aws_config_path, 'w') as f:
86+
config.write(f)
87+
PY_EOF
88+
unset aws_sso_start_url
89+
unset aws_sso_region
90+
unset aws_sso_session
91+
unset aws_sso_account_id
92+
unset aws_sso_role_name
4893
# show the user, user amazon resource name (arn), and the account id, of the
4994
# profile set in the AWS_PROFILE environment variable.
95+
if ! aws sts get-caller-identity >/dev/null 2>&1; then
96+
aws sso login
97+
fi
5098
aws sts get-caller-identity
99+
EOF
51100
```
52101

53-
Or, set the AWS Account credentials using an Access Key:
102+
Or, set the AWS Account credentials using an Access Key, e.g.:
54103

55104
```bash
56105
# set the account credentials.
57106
# NB get these from your aws account iam console.
58107
# see Managing access keys (console) at
59108
# https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey
109+
cat >secrets.sh <<'EOF'
60110
export AWS_ACCESS_KEY_ID='TODO'
61111
export AWS_SECRET_ACCESS_KEY='TODO'
62112
unset AWS_PROFILE
63113
# set the default region.
64114
export AWS_DEFAULT_REGION='eu-west-1'
65115
# show the user, user amazon resource name (arn), and the account id.
66116
aws sts get-caller-identity
117+
EOF
67118
```
68119

69120
Review the [`inputs.tf`](inputs.tf) file.
@@ -77,6 +128,10 @@ terraform init -lockfile=readonly
77128
Deploy the example:
78129

79130
```bash
131+
export CHECKPOINT_DISABLE='1'
132+
export TF_LOG='DEBUG' # TRACE, DEBUG, INFO, WARN or ERROR.
133+
export TF_LOG_PATH='terraform.log'
134+
rm -f "$TF_LOG_PATH"
80135
terraform apply
81136
```
82137

0 commit comments

Comments
 (0)