Created
June 3, 2022 03:08
-
-
Save osule/0881e7d93569dcd4bc904540c900ae44 to your computer and use it in GitHub Desktop.
List S3 buckets in an account with Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# List the S3 buckets in an account | |
aws s3api list-buckets | jq '[.Buckets[]] | map({ (.Name): .Name }) | add' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "external" "buckets" { | |
program = ["./list-buckets.sh"] | |
} | |
output "json" { | |
# List of bucket names | |
value = values(data.external.buckets.result) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment