-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds barebones terraform example (#857)
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Terraform | ||
This example demonstrates how to use Zarf to execute Terraform code to create an S3 bucket. | ||
|
||
### Assumptions/Prereqs | ||
- The binaries in the Zarf package are for an M1 Mac only and will need to be changed for other architectures | ||
- The S3 bucket name will likely need to be changed as S3 bucket names must be globally unique | ||
- Your machine has a connection to an AWS instance and is authenticated with an AWS account | ||
|
||
### Steps | ||
|
||
No K8s cluster is necessary, just build with the package with: | ||
|
||
`zarf package create` | ||
|
||
And execute with: | ||
|
||
`zarf package deploy <package_name>` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "4.33.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_s3_bucket" "example-bucket" { | ||
# note this bucket name will need to be changed because s3 buckets must be globally unique | ||
bucket = "unclegedds-example-bucket" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
kind: ZarfPackageConfig | ||
metadata: | ||
name: "terraform" | ||
description: "Run terraform/terragrunt code" | ||
|
||
components: | ||
- name: download-terraform | ||
required: true | ||
scripts: | ||
after: | ||
- "rm -f terraform" | ||
- "./zarf tools archiver decompress tmp/terraform_1.3.1_darwin_arm64.zip ." | ||
- "./zarf tools archiver decompress tmp/terraform-provider-aws_4.33.0_darwin_arm64.zip ./tf-plugins/registry.terraform.io/hashicorp/aws/4.33.0/darwin_arm64" | ||
- "rm -rf tmp" | ||
files: | ||
# terraform code | ||
- source: main.tf | ||
target: main.tf | ||
# mac m1 terraform aws provider binary | ||
- source: https://releases.hashicorp.com/terraform-provider-aws/4.33.0/terraform-provider-aws_4.33.0_darwin_arm64.zip | ||
target: tmp/terraform-provider-aws_4.33.0_darwin_arm64.zip | ||
# mac m1 terraform binary | ||
- source: https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_darwin_arm64.zip | ||
target: tmp/terraform_1.3.1_darwin_arm64.zip | ||
|
||
- name: execute-terraform | ||
scripts: | ||
timeoutSeconds: 60 | ||
showOutput: true | ||
before: | ||
- "./terraform init -plugin-dir=tf-plugins" | ||
- "./terraform apply -auto-approve" |