terraform.aws-baseline-infra/modules/util/awscli
2023-07-01 16:52:19 +08:00
..
awsWithAssumeRole.sh NEW: modules for assume role in shell and awscli 2023-07-01 16:52:19 +08:00
main.tf NEW: modules for assume role in shell and awscli 2023-07-01 16:52:19 +08:00
README.md NEW: modules for assume role in shell and awscli 2023-07-01 16:52:19 +08:00
variables.tf NEW: modules for assume role in shell and awscli 2023-07-01 16:52:19 +08:00

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",
]