-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1ec834
commit 4070fc5
Showing
9 changed files
with
365 additions
and
11 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 |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
# Local values for vars | ||
terraform.tfvars | ||
.idea/ | ||
|
||
.build-harness | ||
build-harness |
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,16 @@ | ||
addons: | ||
apt: | ||
packages: | ||
- git | ||
- make | ||
- curl | ||
|
||
install: | ||
- make init | ||
|
||
script: | ||
- make terraform/install | ||
- make terraform/get-plugins | ||
- make terraform/get-modules | ||
- make terraform/lint | ||
- make terraform/validate |
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,10 @@ | ||
SHELL := /bin/bash | ||
|
||
# List of targets the `readme` target should call before generating the readme | ||
export README_DEPS ?= docs/targets.md docs/terraform.md | ||
|
||
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) | ||
|
||
## Lint terraform code | ||
lint: | ||
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validateplugins terraform/lint terraform/validate |
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
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,98 @@ | ||
--- | ||
# | ||
# This is the canonical configuration for the `README.md` | ||
# Run `make readme` to rebuild the `README.md` | ||
# | ||
|
||
# Name of this project | ||
name: terraform-aws-ec2-ami-snapshot | ||
|
||
# Logo for this project | ||
#logo: docs/logo.png | ||
|
||
# License of this project | ||
license: "APACHE2" | ||
|
||
# Canonical GitHub repo | ||
github_repo: cloudposse/terraform-aws-ec2-ami-snapshot | ||
|
||
# Badges to display | ||
badges: | ||
- name: "Build Status" | ||
image: "https://travis-ci.org/cloudposse/terraform-aws-ec2-ami-snapshot.svg?branch=master" | ||
url: "https://travis-ci.org/cloudposse/terraform-aws-ec2-ami-snapshot" | ||
- name: "Latest Release" | ||
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-ec2-ami-snapshot.svg" | ||
url: "https://travis-ci.org/cloudposse/terraform-aws-ec2-ami-snapshot/releases" | ||
- name: "Slack Community" | ||
image: "https://slack.cloudposse.com/badge.svg" | ||
url: "https://slack.cloudposse.com" | ||
|
||
related: | ||
- name: "terraform-aws-ec2-ami-backup" | ||
description: "Terraform module for automatic & scheduled AMI creation" | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-ami-backup" | ||
- name: "terraform-aws-ec2-bastion-server" | ||
description: "Terraform Module to define a generic Bastion host with parameterized user_data" | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-bastion-server" | ||
- name: "terraform-aws-ec2-instance" | ||
description: "Terraform Module for providing a general EC2 instance provisioned by Ansible" | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-instance" | ||
- name: "terraform-aws-ec2-admin-server" | ||
description: "Terraform Module for providing a EC2 instance capable of running admin tasks and provisioned by Ansible" | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-admin-server" | ||
- name: "terraform-aws-ec2-cloudwatch-sns-alarms" | ||
description: "Terraform module that configures CloudWatch SNS alerts for EC2 instances" | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-cloudwatch-sns-alarms" | ||
- name: "terraform-aws-ec2-instance-group" | ||
description: "Terraform Module for provisioning multiple general purpose EC2 hosts for stateful applications." | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-instance-group" | ||
- name: "terraform-aws-ec2-instance-group" | ||
description: "Terraform Module for provisioning multiple general purpose EC2 hosts for stateful applications." | ||
url: "https://github.com/cloudposse/terraform-aws-ec2-instance-group" | ||
|
||
# Short description of this project | ||
description: |- | ||
Terraform module to easily generate AMI snapshots to create replica instances | ||
# How to use this project | ||
usage: |- | ||
### Create an AWS instance | ||
``` | ||
resource "aws_instance" "default" { | ||
ami = "ami-408c7f28" | ||
instance_type = "t1.micro" | ||
tags = { | ||
Name = "test1" | ||
} | ||
} | ||
``` | ||
### Create AMI from an AWS instance. Instance ID is required" | ||
``` | ||
module "tf_ami_from_instance" { | ||
source = "git::https://github.com/cloudposse/tf_ami_from_instance.git?ref=master" | ||
source_instance_id = "${aws_instance.web.id}" | ||
stage = "${var.stage}" | ||
namespace = "${var.namespace}" | ||
name = "${var.name}" | ||
attributes = "${var.attributes}" | ||
tags = "${var.tags}" | ||
} | ||
``` | ||
## Caveats | ||
* Terraform will only keep the latest AMI snapshot (terraform will delete the previously generated AMI) See our Lamda based solution which avoids this pitfall: https://github.com/cloudposse/tf_lambda_ami_backup | ||
* This is is not compatible with autoscaling groups | ||
include: | ||
- "docs/targets.md" | ||
- "docs/terraform.md" | ||
|
||
# Contributors to this project | ||
contributors: | ||
- name: "Sergey Vasilyev" | ||
github: "s2504s" |
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,9 @@ | ||
## Makefile Targets | ||
``` | ||
Available targets: | ||
help This help screen | ||
help/all Display help for all targets | ||
lint Lint terraform code | ||
``` |
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,20 @@ | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| attributes | Additional attributes (e.g. `policy` or `role`) | list | `<list>` | no | | ||
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | | ||
| name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | `` | no | | ||
| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | `` | no | | ||
| snapshot_without_reboot | | string | `true` | no | | ||
| source_instance_id | | string | - | yes | | ||
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `` | no | | ||
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map | `<map>` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| ami_id | AMI ID depends on the instance type and region in which you're launching your stack. And IDs can change regularly, such as when an AMI is updated with software updates. | | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
output "ami_id" { | ||
value = "${aws_ami_from_instance.default.id}" | ||
description = "AMI ID depends on the instance type and region in which you're launching your stack. And IDs can change regularly, such as when an AMI is updated with software updates." | ||
value = "${aws_ami_from_instance.default.id}" | ||
} |
Oops, something went wrong.