Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sduff/c6cae4b236fc3450ccaaed0677e8e313 to your computer and use it in GitHub Desktop.
Save sduff/c6cae4b236fc3450ccaaed0677e8e313 to your computer and use it in GitHub Desktop.
Accessing Confluent Cloud resource identifiers after running the terraform provider
# 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