Skip to content

Instantly share code, notes, and snippets.

@apparentlymart
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apparentlymart/755950a802f7c8ad2c00 to your computer and use it in GitHub Desktop.
Save apparentlymart/755950a802f7c8ad2c00 to your computer and use it in GitHub Desktop.
Example configs for Terraform-based build tool (codename Padstone)
provider "aws" {
region = "us-west-2"
}
provider "aws" {
region = "us-west-1"
alias = "us-west-1"
}
temporary_resource "aws_instance" "source" {
// ..
key_name = "${aws_keypair.provisioning.name}"
connection {
type = "ssh"
user = "ubuntu"
key_file = "provisioning_private_key"
}
provisioner "chef" {
// ..
}
}
temporary_resource "aws_keypair" "provisioning" {
// ...
}
// Result resources are created after the temporaries and will live on after the
// build is complete. The resources described in here will appear in the
// Terraform-style state that results from the build, as if there were
// a referenced terraform module named after the artifact.
resource "aws_ami_from_instance" "usw2" {
// Intermediate resources can be used here as long as the result resources won't
// block the destruction of the temporaries.
source_instance = "${aws_instance.source.id}"
}
resource "aws_ami_from_remote_region" "usw1" {
source_region = "us-west-2"
source_ami_id = "${aws_ami_from_instance.usw2.id}"
provider = "aws.us-west-1"
}
output "usw1_ami_id" {
value = "${aws_ami_from_remote_region.usw1.id}"
}
output "usw2_ami_id" {
value = "${aws_ami_from_instance.usw2.id}"
}
// The state can be written to a remote
// storage location so it can easily be consumed by a
// terraform_remote_state resource in a downstream Terraform build.
state_storage {
backend = "s3"
config = {
bucket = "padstone-results"
key = "ami"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment