Skip to content

Commit 447b2ca

Browse files
committed
terraform: Hoist aws_profile into the terraform Kconfig
Enable automation to select among several AWS profiles by storing the AWS profile name in the kdevops Kconfig. This allows each test runner to use a distinct IAM user. This is a way to parallelize the workflows. Reviewed-by: Luis Chamberlain <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 6a45601 commit 447b2ca

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

docs/kdevops-terraform.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ aws_access_key_id = SOME_ACCESS_KEY
238238
aws_secret_access_key = SECRET_KEY
239239
```
240240

241-
The profile above is "default", and you can multiple profiles. By default
242-
our Terraform's AWS vars.tf assumes ~/.aws/credentials as the default
243-
credentials location, and the profile as "default". If this is different
244-
for you, you can override with the variables:
241+
The profile above is "default", and you can have multiple profiles. By
242+
default our Terraform's AWS vars.tf assumes ~/.aws/credentials as the
243+
default credentials location, and the profile as "default". If this is
244+
different for you, you can override with the variables:
245245

246246
```
247247
aws_shared_credentials_file

playbooks/roles/gen_tfvars/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ terraform_private_net_enabled: "false"
1717
terraform_private_net_prefix: ""
1818
terraform_private_net_mask: 0
1919

20+
terraform_aws_profile: "default"
2021
terraform_aws_region: "invalid"
2122
terraform_aws_av_region: "invalid"
2223
terraform_aws_ami_owner: "invalid"

playbooks/roles/gen_tfvars/templates/aws/terraform.tfvars.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
aws_profile = "{{ terraform_aws_profile }}"
12
aws_region = "{{ terraform_aws_region }}"
23
aws_availability_region = "{{ terraform_aws_av_region }}"
34
aws_name_search = "{{ terraform_aws_ns }}"

scripts/terraform.Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ KDEVOPS_MRPROPER += $(KDEVOPS_NODES)
4646
DEFAULT_DEPS_REQS_EXTRA_VARS += $(KDEVOPS_TFVARS)
4747

4848
ifeq (y,$(CONFIG_TERRAFORM_AWS))
49+
TERRAFORM_EXTRA_VARS += terraform_aws_profile=$(subst ",,$(CONFIG_TERRAFORM_AWS_PROFILE))
4950
TERRAFORM_EXTRA_VARS += terraform_aws_region=$(subst ",,$(CONFIG_TERRAFORM_AWS_REGION))
5051
TERRAFORM_EXTRA_VARS += terraform_aws_av_region=$(subst ",,$(CONFIG_TERRAFORM_AWS_AV_REGION))
5152
TERRAFORM_EXTRA_VARS += terraform_aws_ami_owner=$(subst ",,$(CONFIG_TERRAFORM_AWS_AMI_OWNER))

terraform/aws/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
if TERRAFORM_AWS
22

3+
config TERRAFORM_AWS_PROFILE
4+
prompt "AWS profile to use"
5+
string
6+
default "default"
7+
help
8+
This option sets the value of the Terraform aws_profile
9+
variable. The AWS profile specifies an IAM user and secret
10+
key that Terraform uses to authenticate to AWS.
11+
12+
AWS profiles are set up in ~/.aws/credentials using the
13+
"aws configure" command. You may also edit this file by
14+
hand, if you're daring.
15+
16+
The default value of this Kconfig option selects the
17+
"default" profile, which is fine when using only a single
18+
AWS profile. Change the value of this option to select an
19+
alternate profile / login credentials.
20+
321
choice
422
prompt "AWS region to use"
523
default TERRAFORM_AWS_US_WEST_2

0 commit comments

Comments
 (0)