56 lines
1.8 KiB
Markdown
56 lines
1.8 KiB
Markdown
# awscli module
|
|
This module executes awscli and returns the output.
|
|
|
|
# input variables
|
|
Set the temp credentials if role switching is needed. Otherwise, leave them alone.
|
|
|
|
| variable | type | required | description |
|
|
|------------------|---------|----------|-------------------------------------|
|
|
| access_key | string | no | for role switching |
|
|
| secret_key | string | no | for role switching |
|
|
| session_token | string | no | for role switching |
|
|
| aws_cli_commands | string | yes | command and parameters after `aws` |
|
|
|
|
# output variable
|
|
Normally terraform only produces a simple map of string in output. To work
|
|
around this, awscli outout are base64 encoded. The output variable is then
|
|
base64decoded back to the original text.
|
|
|
|
| variable | type | description |
|
|
|:--------------|:-------|:-------------------|
|
|
| awscli_output | string | output from awscli |
|
|
|
|
## Usage example
|
|
```hcl
|
|
module "awscli_exec" {
|
|
source = "../../modules/util/awscli"
|
|
|
|
access_key = module.as_role.temp_credential.AccessKeyId
|
|
secret_key = module.as_role.temp_credential.SecretAccessKey
|
|
session_token = module.as_role.temp_credential.SessionToken
|
|
aws_cli_commands = "ec2 describe-instances --query Reservations[].Instances[].InstanceId"
|
|
}
|
|
|
|
output awscli_output {
|
|
value = module.awscli_exec.awscliout
|
|
}
|
|
```
|
|
|
|
Output
|
|
```
|
|
Outputs:
|
|
|
|
awscli_output = [
|
|
"i-0cd5e682bc68dbcd2",
|
|
"i-050d4adeafaa53cd0",
|
|
"i-008328e9dfb56b883",
|
|
"i-0634c5ef3528a7b6f",
|
|
"i-0dc9009c249f3e3bd",
|
|
"i-08034d509751ff058",
|
|
"i-0bdd375df2b78a620",
|
|
"i-0655d2b3716b1383e",
|
|
]
|
|
```
|
|
|
|
# References
|
|
This module is based on https://registry.terraform.io/modules/digitickets/cli/aws/latest |