Created
October 6, 2021 06:29
-
-
Save sduff/c6cae4b236fc3450ccaaed0677e8e313 to your computer and use it in GitHub Desktop.
Accessing Confluent Cloud resource identifiers after running the terraform provider
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
# Use jq to read the terraform state file | |
# all id's | |
jq '.resources[].instances[].attributes.id?' terraform.tfstate | |
# all display names | |
jq '.resources[].instances[].attributes.display_name?' terraform.tfstate | |
# all environment id's | |
jq '.resources[].instances[].attributes.environment[]?.id' | |
# We can include the identifiers in the terraform output with the following | |
output "env_id" { | |
value = confluentcloud_environment.env.id | |
} | |
output "cluster_id" { | |
value = confluentcloud_kafka_cluster.test-basic-cluster.id | |
} | |
# variables are easily accessible with grep and sed | |
# cluster id | |
terraform output | grep cluster | sed 's:^.*"\(.*\)"$:\1:g' | |
# environment id | |
terraform output | grep env | sed 's:^.*"\(.*\)"$:\1:g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment