Skip to content

Instantly share code, notes, and snippets.

@clstokes

clstokes/main.tf Secret

Last active October 4, 2021 17:27
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 clstokes/80cddb26e2defd708d499ed0c081d87c to your computer and use it in GitHub Desktop.
Save clstokes/80cddb26e2defd708d499ed0c081d87c to your computer and use it in GitHub Desktop.
Reference a Pulumi stack state from Terraform
# Use the external data source to query Pulumi stack state.
# https://www.terraform.io/docs/providers/external/data_source.html
#
# Requires the `pulumi` command-line tool to be installed
# and a `PULUMI_ACCESS_TOKEN` environment variable when executing Terraform
# in order to authenticate with the Pulumi Console.
variable "pulumi_stack" {
default = "clstokes/pulumi-cloudtrail-athena/dev"
# The outputs for this particular stack look like this:
# {
# "accountIdX": "052848974346",
# "bucketNameX": "cloudtrail-data-cameronstokes-pulumi",
# "databaseName": "cloudtrail_f4dcfba"
# }
}
data "external" "pulumi" {
program = ["pulumi", "stack", "output","--json", "--stack", var.pulumi_stack]
}
output "database_name" {
value = data.external.pulumi.result.databaseName
}
% terraform apply
data.external.pulumi: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
database_name = cloudtrail_f4dcfba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment