Skip to content

Latest commit

 

History

History
151 lines (119 loc) · 3.92 KB

File metadata and controls

151 lines (119 loc) · 3.92 KB

EBS Snapshot acquisition and generation management

Get the EBSSnapshot, perform the generation management. To identify the target of volume to get a snapshot There are three ways.

Usage

To create a role that is set to LambdaFunction (LambdaEBSSnapshotRole)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": [
                "arn:aws:logs:*:*:*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeVolumes",
                "ec2:DescribeSnapshots",
                "ec2:CreateSnapshot",
                "ec2:CreateTags",
                "ec2:DescribeTags",
                "ec2:DeleteSnapshot"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "dynamodb:PutItem",
                "dynamodb:UpdateItem"
            ],
            "Resource": [
                "arn:aws:dynamodb:ap-northeast-1:xxxxxxxxxxxx:table/lambda_locks"
            ]
        }
    ]
}

create EBS Snapshot from volume-id

To create a LambdaFunction

  • Name: EBSSnapshotFromVolumeId
  • Runtime: Java8
  • Handler: jp.gr.java_conf.uzresk.aws.ope.ebs.EBSSnapshotFunction::createSnapshotFromVolumeId
  • Role: LambdaEBSSnapshotRole
  • Memory: 512
  • Timeout: According to the number of target

Setting the Cloudwatch event

  • EventSource: Schedule(Any Timing)
  • Target:Lambda function -> EBSSnapshotFromVolumeId
  • Configure input: constant(JSON text)
   {
     "volumeId": "vol-xxxxxxxxxxxxxxxxx",
     "generationCount": "2"
   }

create EBS Snapshot from multiple volume-id

To create a LambdaFunction

  • Name: EBSSnapshotFromVolumeIds
  • Runtime: Java8
  • Handler: jp.gr.java_conf.uzresk.aws.ope.ebs.EBSSnapshotFunction::createSnapshotFromVolumeIds
  • Role: LambdaEBSSnapshotRole
  • Memory: 512
  • Timeout: According to the number of target

Setting the Cloudwatch event

  • EventSource: Schedule(Any Timing)
  • Target:Lambda function -> EBSSnapshotFromVolumeIds
  • Configure input: constant(JSON text)
    {
      "volumeIdRequests": [
        {
          "volumeId": "vol-xxxxxxxxxxxxxxxxx",
          "generationCount": "2"
        },
        {
          "volumeId": "vol-yyyyyyyyyyyyyyyyy",
          "generationCount": "3"
        }
      ]
    }

create EBS Snapshot from tag name

To create a LambdaFunction

  • Name: EBSSnapshotFromTagName
  • Runtime: Java8
  • Handler: jp.gr.java_conf.uzresk.aws.ope.ebs.EBSSnapshotFunction::createSnapshotFromTagName
  • Role: LambdaEBSSnapshotRole
  • Memory: 512
  • Timeout: According to the number of target

Setting the Cloudwatch event

  • EventSource: Schedule(Any Timing)
  • Target:Lambda function -> EBSSnapshotFromTagName
  • Configure input: constant(JSON text)
   {
     "tagName": "test",
     "generationCount": 2
   }

Setting the Backup tag and GenerationCount tag in Volume to be EBSSnapshot target.

  • The GenerationCount to set the number of generation management. If you omit the GenerationCount, generation management number is 10 by default

  • VolumeTags examples

    "Backup":"test",