Skip to content

Instantly share code, notes, and snippets.

@vvondra
Created April 14, 2016 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvondra/ee6edaf08aab2ac0566012fc21e265f8 to your computer and use it in GitHub Desktop.
Save vvondra/ee6edaf08aab2ac0566012fc21e265f8 to your computer and use it in GitHub Desktop.
Backup do S3
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"BackupBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"LifecycleConfiguration": {
"Rules": [
{
"Id": "Move to Glacier",
"Status": "Enabled",
"ExpirationInDays": "160",
"Transition": {
"TransitionInDays": "3",
"StorageClass": "Glacier"
}
}
]
}
}
},
"BackupBucketPolicy" : {
"Type" : "AWS::S3::BucketPolicy",
"Properties" : {
"Bucket" : { "Ref" : "BackupBucket" },
"PolicyDocument" : {
"Version" : "2012-10-17",
"Statement" : [ {
"Sid" : "AllowUploadBackups",
"Effect" : "Allow",
"Principal" : { "AWS" : [ { "Fn::GetAtt" : [ "BackupUser", "Arn" ] } ] },
"Action" : [
"s3:AbortMultipartUpload",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:PutObjectAcl",
"s3:PutObject"
],
"Resource" : { "Fn::Join" : [ "", [
"arn:aws:s3:::",
{ "Ref" : "BackupBucket" },
"/*"
] ] }
} ]
}
}
},
"BackupUser" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Path" : "/"
}
},
"BackupUserKey" : {
"Type" : "AWS::IAM::AccessKey",
"Properties": {
"Status": "Active",
"UserName": { "Ref" : "BackupUser" }
}
}
},
"Outputs": {
"BucketName": {
"Value": {
"Ref": "BackupBucket"
},
"Description": "Name of the sample Amazon S3 bucket with a lifecycle configuration."
},
"BackupUserUserAccessKeyID" : {
"Description" : "Backup user access key ID",
"Value" : { "Ref" : "BackupUserKey" }
},
"BackupUserUserSecretAccessKey" : {
"Description" : "Backup user secret access key",
"Value" : {
"Fn::GetAtt" : ["BackupUserKey", "SecretAccessKey"]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment