Creating a AWS Cloudwatch Event Rule to backup EBS volumes

800 views
Skip to first unread message

Keir Badger

unread,
Dec 22, 2016, 11:58:31 AM12/22/16
to Terraform
Hi

Using Terraform is it possible to create a Cloudwatch rule that runs a scheduled 'create snapshot' on a particular volume

Had a good look at the docs and online but cant seem to find the correct syntax

Thanks for any help

Rgds

Keir


Details of a Rule and Target from one manually created 
Rule
        {
            "State": "ENABLED",
            "ScheduleExpression": "rate(1 hour)",
            "Name": "backup-devops-diskstore",
            "Arn": "arn:aws:events:eu-central-1:498606453616:rule/backup-devops-diskstore",
            "Description": "backup-devops-diskstore"
        }

Target
    "Targets": [
        {
            "Input": "\"arn:aws:ec2:eu-central-1:1234567890:volume/vol-12345678\"",
            "Id": "Id372662439390",
            "Arn": "arn:aws:automation:eu-central-1:1234567890:action/EBSCreateSnapshot/EBSCreateSnapshot_backup-devops-diskstore"
        }
    ]


Keir Badger

unread,
Dec 22, 2016, 12:06:56 PM12/22/16
to Terraform
 I get this far - cant figure out how to gt input and arn for the event target and not even sure if I am on the right track

Cheers

Keir 

resource "aws_cloudwatch_event_rule" "console" {
  name = "every-hour"
  description = "every hour"
  schedule_expression="rate(1 hour)"

}

resource "aws_cloudwatch_event_target" "backup" {
  arn = ???
  input = ????

Franck Ratier

unread,
Mar 21, 2017, 7:52:15 AM3/21/17
to Terraform
Hi Keir,

I was looking at this too but it seems you can only do it via the AWS Console as stated here:

Creating rules with built-in targets is supported only in the AWS Management Console.

Cheers,

Franck
Reply all
Reply to author
Forward
0 new messages