Once the CloudFormation connector for Terraform is installed, you can begin to use the new custom type
Cloudsoft::Terraform::Infrastructure
to deploy Terraform configuration. This can be added along side any other CloudFormation
resources.
To declare this type in your CloudFormation template, use the following syntax,
with exactly one Configuration
property specified.
The URL and S3 variants can point at a TF
text file or a ZIP
archive.
{
"Type" : "Cloudsoft::Terraform::Infrastructure",
"Properties" : {
"Variables": {
"variable1": "string1",
"variable2": "string2",
"variable3": "string3"
},
"ConfigurationContent": "String",
"ConfigurationUrl": "String",
"ConfigurationS3Path": "String"
}
}
Type: Cloudsoft::Terraform::Infrastructure
Properties:
Variables:
variable1: string1
variable2: string2
variable3: string3
ConfigurationContent: String
ConfigurationUrl: String
ConfigurationS3Path: String
Key | Description | Required |
---|---|---|
ConfigurationContent |
Inlined Terraform configuration text to be uploaded to the Terraform server. | Conditional. Exactly one of ConfigurationContent , ConfigurationUrl or ConfigurationS3Path must be specified. |
ConfigurationUrl |
Public HTTP URL of a Terraform configuration. This will be downloaded from within CloudFormation and uploaded to the Terraform server. | (as above) |
ConfigurationS3Path |
S3 path object representing a Terraform configuration. The current account must have access to this resource. This will be downloaded from within CloudFormation and uploaded to the Terraform server. | (as above) |
Variables |
Variables to make available to the Terraform configuration by means of an .auto.tfvars.json file. |
Optional in the CloudFormation template, although may be required by the Terraform configuration. |
LogBucketName |
The name of an S3 bucket to create (if not present) and write log files. This property value can contain a * character which will be replaced by the model's identifier, ensuring creation of a new bucket for each stack which the user will have access to. If the value does not contain * the bucket should either be intended for a single user or else manually configured with appropriate permissions for all users to see and for this resource provider to write to, otherwise the bucket may be unusable or inaccessible to some. Restrictions on bucket names apply (between 3 and 63 characters long, no capital letters, etc). |
Optional; useful if the Terraform is not behaving as expected |
The resource provider will set the following outputs on the resource.
Key | Type | Description |
---|---|---|
Outputs |
Object | All output coming from the Terraform configuration, as a map. |
OutputsStringified |
String | All output coming from the Terraform configuration, as a JSON string of the map. |
LogBucketUrl |
String | A URL where logs can be found if S3 logs are configured. Note that this is only set if a log bucket is explicitly requested, either with the LogBucketName property in CFN or a /cfn/terraform/logs-s3-bucket-name parameter in SSM. |
You can use the Fn::GetAtt
intrinsic function to access these values,
e.g. in the Outputs
section of your CloudFormation to set an output on the stack and see it.
(At present there is no other way to see these values without inspecting the logs.)
It can also sometimes be useful to send the OutputsStringified
to another Lambda to parse the JSON
and retrieve selected fields for use elsewhere in your stack.
(At present it is not possible using Fn::GetAtt
to access a specific field within the Outputs
.)