|
1 | 1 | package aws
|
2 | 2 |
|
| 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 | + |
3 | 10 | // Config is the configuration for the ruleset.
|
4 | 11 | 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"` |
11 | 19 | }
|
12 | 20 |
|
13 | 21 | func (c *Config) toCredentials() Credentials {
|
14 |
| - return Credentials{ |
| 22 | + credentials := Credentials{ |
15 | 23 | AccessKey: c.AccessKey,
|
16 | 24 | SecretKey: c.SecretKey,
|
17 | 25 | Region: c.Region,
|
18 | 26 | Profile: c.Profile,
|
19 | 27 | CredsFile: c.SharedCredentialsFile,
|
20 | 28 | }
|
| 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 |
21 | 38 | }
|
0 commit comments