Merges HCL configuration files to consolidate settings and resources efficiently.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| options | any | - | |
| aSourceContent | string | The HCL content to be merged | |
| bSourceContent | string | The HCL content to be merged |
Output Schema
| Property | Type | Description | Required |
|---|---|---|---|
| hcl | string | - |
Usage Examples
Merge environment variables into terraform.tfvars
Merge environment-specific variables into an existing terraform.tfvars file during scaffolding. This fits after fetching a base template with fetch:template and before publishing with github:publish.
steps:
- id: fetch-base
action: fetch:template
input:
url: https://github.com/example-org/terraform-service-template/archive/main.zip
targetPath: .
- id: merge-tfvars
action: hcl:merge
input:
path: infra/environments/${{ parameters.env }}/terraform.tfvars
content: |
region = "${{ parameters.region }}"
instance_type = "${{ parameters.instanceType }}"
enable_logging = ${{ parameters.enableLogging }}
tags = {
service = "${{ parameters.serviceName }}"
owner = "${{ user.entity.metadata.name }}"
env = "${{ parameters.env }}"
}
- id: publish
action: github:publish
input:
repoUrl: github.com?owner=example-org&repo=${{ parameters.repoName }}
defaultBranch: mainUpdate Terraform backend configuration in backend.tf
Add or update a Terraform S3 backend block based on template parameters. Use this when standardizing remote state across environments before publishing with github:publish.
steps:
- id: fetch-base
action: fetch:template
input:
url: https://github.com/example-org/terraform-infra-skeleton/archive/main.zip
targetPath: .
- id: merge-backend
action: hcl:merge
input:
path: infra/backend.tf
content: |
terraform {
backend "s3" {
bucket = "company-tfstate-${{ parameters.env }}"
key = "${{ parameters.repoName }}/terraform.tfstate"
region = "${{ parameters.region }}"
encrypt = true
dynamodb_table = "tf-locks-${{ parameters.env }}"
}
}
- id: publish
action: github:publish
input:
repoUrl: github.com?owner=example-org&repo=${{ parameters.repoName }}
defaultBranch: main