This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for the packer-vpc module.
- Loading branch information
Showing
3 changed files
with
101 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,30 @@ | ||
# Hardcoding value of 3 minutes when we check if the plan file is stale | ||
STALE_PLAN_FILE := `find "tf.out" -mmin -3 | grep -q tf.out` | ||
|
||
## Check if tf.out is stale (Older than 2 minutes) | ||
check-plan-file: | ||
@if ! ${STALE_PLAN_FILE} ; then \ | ||
echo "ERROR: Stale tf.out plan file (older than 3 minutes)!"; \ | ||
exit 1; \ | ||
fi | ||
|
||
## Runs terraform get and terraform init for env | ||
init: | ||
@terraform get | ||
@terraform init | ||
|
||
## terraform plan (makes everything) | ||
plan: | ||
@terraform plan -out=tf.out | ||
|
||
## terraform apply | ||
apply: check-plan-file | ||
@terraform apply tf.out | ||
|
||
# clean up terrform and any other files | ||
clean: | ||
@terraform destroy | ||
@rm -f tf.out | ||
@rm -f terraform.tfvars | ||
@rm -f terraform.*.backup | ||
@rm -f terraform.tfstate |
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,33 @@ | ||
# Example to test the packer-vpc module. | ||
|
||
An example to demonstrate the [packer-vpc](https://github.com/fpco/terraform-aws-foundation/tree/master/modules/packer-vpc) module. | ||
This will use the `packer-vpc` module to create a simple, isolated VPC on AWS which can be dedicated to building AMI's with `packer`. | ||
|
||
|
||
## Using the Example | ||
|
||
### Environment creation and deployment | ||
|
||
To use this example set up AWS credentials and then run the commands in the | ||
following order: | ||
|
||
``` | ||
make init | ||
make plan | ||
make apply | ||
``` | ||
|
||
Or simply run the following: | ||
|
||
``` | ||
make init && make plan && make apply | ||
``` | ||
|
||
### Destruction | ||
|
||
To destroy the test environment and other resources created by the example run the following command: | ||
|
||
``` | ||
make clean | ||
``` | ||
|
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,38 @@ | ||
variable "region" { | ||
default = "us-west-1" | ||
description = "The AWS region to deploy to" | ||
} | ||
|
||
provider "aws" { | ||
region = "${var.region}" | ||
} | ||
|
||
module "vpc" { | ||
source = "../../modules/packer-vpc" | ||
region = "${var.region}" | ||
} | ||
|
||
output "region" { | ||
value = "${var.region}" | ||
description = "region" | ||
} | ||
|
||
output "vpc_id" { | ||
value = "${module.vpc.vpc_id}" | ||
description = "VPC ID" | ||
} | ||
|
||
output "subnet_id" { | ||
value = "${module.vpc.subnet_id}" | ||
description = "Subnet ID" | ||
} | ||
|
||
output "trusty_ami_id" { | ||
value = "${module.vpc.trusty_ami_id}" | ||
description = "ID of latest trusty AMI" | ||
} | ||
|
||
output "xenial_ami_id" { | ||
value = "${module.vpc.xenial_ami_id}" | ||
description = "ID of latest xenial AMI" | ||
} |
daac984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is intended to address issue #95