terraform.aws-baseline-infra/modules/util/awscli/README.md

873 B

awscli module

This module executes awscli. Json output goes through base64 encode and decode to work around terraform map of string requirements for external data.

Example root module

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
}

Sample output

Outputs:

awscli_output = [
  "i-0cd5e682bc68dbcd2",
  "i-050d4adeafaa53cd0",
  "i-008328e9dfb56b883",
  "i-0634c5ef3528a7b6f",
  "i-0dc9009c249f3e3bd",
  "i-08034d509751ff058",
  "i-0bdd375df2b78a620",
  "i-0655d2b3716b1383e",
]