Using Terraform Remote State with Pulumi
While some people coming to Pulumi are entirely new to Infrastructure as Code, increasingly teams are moving from other tools - whether cloud-specific in the form of CloudFormation or ARM Templates, or cloud-agnostic tools such as Terraform. In these organizations, new infrastructure provisioned with Pulumi must co-exist with existing resources provisioned with other tools, and often by different teams. For example, it’s common to see an application team deploying into a VPC owned and managed by a network operations team.
Pulumi supports
this kind of workflow
natively using the StackReference
type from the Pulumi SDK. Integration with the most popular
cloud-specific tools have been supported by Pulumi since the earliest
days:
The
aws.cloudformation.getStack()
function can be used to obtain the outputs from a CloudFormation Stack.The
get
method of theazure.core.TemplateDeployment
class can be used to obtain the outputs of an ARM Template Deployment.
We recently added similar support for reading the outputs of a Terraform
state file - both from local .tfstate
files, and from all of the
remote state backends supported by Terraform. This is exposed via the
terraform.state.RemoteStateReference
type in the
@pulumi/terraform
NPM package.