Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created TF module to perform AMI backups using Lamda Functions #2

Merged
merged 15 commits into from
Aug 11, 2017

Conversation

const-bon
Copy link

What

  • Create AMIs periodically for a backup purpose

Why

  • We will have option to backup and restore EC2 instances state fast

References

@const-bon const-bon self-assigned this Aug 10, 2017
main.tf Outdated

statement {
actions = [
"ec2:*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use more precise ACLs

Copy link
Author

@const-bon const-bon Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

      "ec2:DescribeInstances",
      "ec2:CreateImage",
      "ec2:CreateTags"

main.tf Outdated
resource "aws_lambda_function" "ami_backup" {
filename = "${path.module}/lambda_ami_backups.zip"
function_name = "${module.label_backup.id}"
description = "Automatically backs up instances tagged with backup: true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with Automatically backup instances tagged with 'backup: true'

main.tf Outdated
resource "aws_lambda_function" "ami_cleanup" {
filename = "${path.module}/lambda_ami_cleanups.zip"
function_name = "${module.label_cleanup.id}"
description = "Cleans up old AMI backups"
Copy link
Member

@osterman osterman Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup old AMI backups

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with Cleanup old AMI backups

main.tf Outdated

resource "aws_cloudwatch_event_rule" "ami_backup" {
name = "${module.label_backup.id}"
description = "Schedule for ami snapshot backups"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMI

Copy link
Author

@const-bon const-bon Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with Schedule for AMI snapshot backups

main.tf Outdated

resource "aws_cloudwatch_event_rule" "ami_cleanup" {
name = "${module.label_cleanup.id}"
description = "Schedule for ami snapshot cleanup"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMI

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with Schedule for AMI snapshot cleanup

main.tf Outdated

resource "aws_cloudwatch_event_target" "ami_backup" {
rule = "${aws_cloudwatch_event_rule.ami_backup.name}"
target_id = "schedule_ami_backups"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be namespaced

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with target_id = "${module.label_backup.id}"

main.tf Outdated

resource "aws_cloudwatch_event_target" "ami_cleanup" {
rule = "${aws_cloudwatch_event_rule.ami_cleanup.name}"
target_id = "schedule_ami_cleanups"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be namespaced?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with target_id = "${module.label_cleanup.id}"

@const-bon
Copy link
Author

Applied all required fixes.
@osterman please check.

main.tf Outdated
resource "aws_lambda_function" "ami_backup" {
filename = "${path.module}/ami_backup.zip"
function_name = "${module.label_backup.id}"
description = "Automatically backup instances tagged with 'backup: true'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshot: true

@const-bon const-bon merged commit 7f8101d into master Aug 11, 2017
@const-bon const-bon deleted the lambda_ami_review branch August 11, 2017 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants