Skip to content

Commit 2d7d669

Browse files
authored
chore(GROW-2960): support access keys for AWS Agentless multiple scanning regions (#1659)
* chore(GROW-2960): support custerm attributes for AWS Agentless scanning acounts * chore: fix gitlint workflow * chore: add sudo * chore: another try * chore: another try * chore: another try
1 parent 97a45bc commit 2d7d669

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.github/workflows/commit-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install gitlint
1717
shell: bash
1818
run: |
19-
python -m pip install gitlint
19+
python -m pip install gitlint --break-system-packages
2020
2121
- name: Run gitlint
2222
shell: bash

lwgenerate/aws/aws.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -909,22 +909,34 @@ func createAwsProvider(args *GenerateAwsTfConfigurationArgs) ([]*hclwrite.Block,
909909
seenAccounts := []string{}
910910

911911
for _, account := range accounts {
912-
alias := fmt.Sprintf("%s-%s", account.AwsProfile, account.AwsRegion)
912+
alias := account.AwsRegion
913913
if account.Alias != "" {
914914
alias = account.Alias
915+
} else if account.AwsProfile != "" {
916+
alias = fmt.Sprintf("%s-%s", account.AwsProfile, account.AwsRegion)
915917
}
916918
// Skip duplicate account
917919
if slices.Contains(seenAccounts, alias) {
918920
continue
919921
}
920922
seenAccounts = append(seenAccounts, alias)
923+
924+
attributes := map[string]interface{}{}
925+
// set `access_key`, `secret_key` and `token` for single-account multiple-region Agentless
926+
if args.Agentless {
927+
for k, v := range args.ExtraProviderArguments {
928+
attributes[k] = v
929+
}
930+
}
931+
attributes["alias"] = alias
932+
attributes["region"] = account.AwsRegion
933+
if args.AwsProfile != "" {
934+
attributes["profile"] = account.AwsProfile
935+
}
936+
921937
providerBlock, err := lwgenerate.NewProvider(
922938
"aws",
923-
lwgenerate.HclProviderWithAttributes(map[string]interface{}{
924-
"alias": alias,
925-
"profile": account.AwsProfile,
926-
"region": account.AwsRegion,
927-
}),
939+
lwgenerate.HclProviderWithAttributes(attributes),
928940
).ToBlock()
929941
if err != nil {
930942
return nil, err

0 commit comments

Comments
 (0)