Skip to content

Commit 5f46668

Browse files
authored
Add assume role configuration in Config struct (#405)
* first commit * Add assume role configuration in Config struct * Fix spacing * Fix spacing * Change to declare `assume_role` block like a Terraform
1 parent 6fe64dd commit 5f46668

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

aws/config.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
package aws
22

3+
type AssumeRole struct {
4+
RoleARN string `hclext:"role_arn,optional"`
5+
ExternalID string `hclext:"external_id,optional"`
6+
Policy string `hclext:"policy,optional"`
7+
SessionName string `hclext:"session_name,optional"`
8+
}
9+
310
// Config is the configuration for the ruleset.
411
type Config struct {
5-
DeepCheck bool `hclext:"deep_check,optional"`
6-
AccessKey string `hclext:"access_key,optional"`
7-
SecretKey string `hclext:"secret_key,optional"`
8-
Region string `hclext:"region,optional"`
9-
Profile string `hclext:"profile,optional"`
10-
SharedCredentialsFile string `hclext:"shared_credentials_file,optional"`
12+
DeepCheck bool `hclext:"deep_check,optional"`
13+
AccessKey string `hclext:"access_key,optional"`
14+
SecretKey string `hclext:"secret_key,optional"`
15+
Region string `hclext:"region,optional"`
16+
Profile string `hclext:"profile,optional"`
17+
SharedCredentialsFile string `hclext:"shared_credentials_file,optional"`
18+
AssumeRole *AssumeRole `hclext:"assume_role,block"`
1119
}
1220

1321
func (c *Config) toCredentials() Credentials {
14-
return Credentials{
22+
credentials := Credentials{
1523
AccessKey: c.AccessKey,
1624
SecretKey: c.SecretKey,
1725
Region: c.Region,
1826
Profile: c.Profile,
1927
CredsFile: c.SharedCredentialsFile,
2028
}
29+
30+
if c.AssumeRole != nil {
31+
credentials.AssumeRoleARN = c.AssumeRole.RoleARN
32+
credentials.AssumeRoleExternalID = c.AssumeRole.ExternalID
33+
credentials.AssumeRolePolicy = c.AssumeRole.Policy
34+
credentials.AssumeRoleSessionName = c.AssumeRole.SessionName
35+
}
36+
37+
return credentials
2138
}

0 commit comments

Comments
 (0)