-
-
Save clstokes/80cddb26e2defd708d499ed0c081d87c to your computer and use it in GitHub Desktop.
Reference a Pulumi stack state from 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
# 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 | |
} |
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
% 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