# EFS Backup Solution # # template for efs-backup-solution # **DO NOT DELETE** # # author: aws-solutions-builder@ AWSTemplateFormatVersion: '2010-09-09' Description: (SO0031) - EFS-to-EFS Backup Solution template. Version %%VERSION%% Parameters: # Source EFS on which restore will be performed SrcEFS: Description: Source EFS Id Type: String AllowedPattern: .+ ConstraintDescription: cannot be blank # Interval tag for your backups; daily, weekly, monthly IntervalTag: Description: Interval label to identify backups Type: String Default: daily AllowedValues: - daily - weekly - monthly # Number of backups you want to retain Retain: Description: Backups you want to retain Type: Number Default: 7 # Folder identifier where backup will be stored FolderLabel: Description: Folder for your backups Type: String Default: efs-backup # Backup window for which backup will run BackupWindow: Description: Backup window duration in minutes Type: Number Default: 180 ConstraintDescription: must specify backup window in minutes AllowedValues: - 60 - 90 - 120 - 150 - 180 - 240 - 300 - 360 - 480 - 600 - 720 - 840 - 960 - 1080 - 1200 - 1320 # Schedule for the backup, cron(0 2 * * ? *) BackupSchedule: Description: "Schedule for running backup. Note: Backup operations should not overlap--especially if scheduling more frequent than daily, take into consideration how long a backup usually takes on the given dataset." Type: String Default: cron(0 2 * * ? *) AllowedPattern: .+ ConstraintDescription: cannot be blank # Source EFS Prefix which you want to backup BackupPrefix: Description: Source prefix for backup Type: String Default: '/' AllowedPattern: .+ ConstraintDescription: cannot be blank # Performance mode for backup EFS EFSMode: Description: Performance mode for backup EFS Type: String Default: generalPurpose AllowedValues: - generalPurpose - maxIO # If customer wants notification for successful backups SuccessNotification: Description: Do you want to be notified for successful backups? *for failure, you will always be notified Type: String AllowedValues: - "Yes" - "No" Default: "Yes" # VPCId for the EFS VpcId: Description: VPC where the source EFS has mount targets Type: AWS::EC2::VPC::Id AllowedPattern: .+ ConstraintDescription: cannot be blank # List of SubnetIDs for EC2, must be same AZ as of EFS Mount Targets (Choose 2) Subnets: Description: List of SubnetIDs for EC2, must be same AZ as of EFS Mount Targets (Choose 2). Must specify subnets in different AZs. Type: List AllowedPattern: .+ ConstraintDescription: cannot be blank # Email for notifications Email: Description: Email for backup notifications Type: String AllowedPattern: .+ ConstraintDescription: cannot be blank # CW Dashboard Dashboard: Description: Do you want dashoard for your metrics? Type: String AllowedValues: - "Yes" - "No" Default: "Yes" # EFS Encryption EFSEncryption: Description: Do you want backup EFS to be encrypted? Type: String AllowedValues: - "Yes" - "No" Default: "Yes" Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: Backup Configuration Parameters: - SrcEFS - IntervalTag - Retain - FolderLabel - BackupWindow - BackupSchedule - BackupPrefix - EFSMode - EFSEncryption - Label: default: EC2 Configuration Parameters: - VpcId - Subnets - Label: default: Notification & Dashboard Parameters: - SuccessNotification - Email - Dashboard ParameterLabels: IntervalTag: default: Interval Label Subnets: default: Subnet IDs SrcEFS: default: Source EFS FolderLabel: default: Folder Label BackupWindow: default: Backup Window BackupSchedule: default: Backup Schedule BackupPrefix: default: Backup Prefix EFSMode: default: EFS Mode SuccessNotification: default: Success Notification VpcId: default: VPC ID EFSEncryption: default: EFS Encryption Mappings: Map: encryption: {"Yes": "true", "No": "false"} send-data: {"SendAnonymousData": "Yes"} c5.xlarge: {"Arch":"HVM64"} us-east-1: {"InstanceSize":"c5.xlarge"} us-east-2: {"InstanceSize":"c5.xlarge"} us-west-1: {"InstanceSize":"c5.xlarge"} us-west-2: {"InstanceSize":"c5.xlarge"} ca-central-1: {"InstanceSize":"c5.xlarge"} eu-west-1: {"InstanceSize":"c5.xlarge"} eu-central-1: {"InstanceSize":"c5.xlarge"} eu-west-2: {"InstanceSize":"c5.xlarge"} ap-southeast-1: {"InstanceSize":"c5.xlarge"} ap-southeast-2: {"InstanceSize":"c5.xlarge"} ap-northeast-1: {"InstanceSize":"c5.xlarge"} ap-northeast-2: {"InstanceSize":"c5.xlarge"} ap-south-1: {"InstanceSize":"c5.xlarge"} sa-east-1: {"InstanceSize":"c5.xlarge"} SourceCode: General: S3Bucket: "%%BUCKET_NAME%%" KeyPrefix: "%%SOLUTION_NAME%%/%%VERSION%%" Conditions: DashboardOpt: !Equals [ !Ref Dashboard, "Yes" ] Resources: # # EFS resources # [EFSSecurityGroup, EFSIngressRule, DstEFS, MountTarget0, MountTarget1] # EFSSecurityGroup: Type: AWS::EC2::SecurityGroup Metadata: cfn_nag: rules_to_suppress: - id: F1000 reason: "allowing all egress traffic" Properties: VpcId: !Sub ${VpcId} GroupDescription: !Sub SG for EFS backup solution ${AWS::StackName} EFSIngressRule: Type: AWS::EC2::SecurityGroupIngress Metadata: cfn_nag: rules_to_suppress: - id: W36 reason: "adding description causes replace during CFN update, causing a stack creation error" - id: W42 reason: Allowing ICMP within the same security group only Properties: FromPort: -1 GroupId: !Sub ${EFSSecurityGroup} IpProtocol: -1 SourceSecurityGroupId: !Sub ${EFSSecurityGroup} ToPort: -1 DstEFS: Type: AWS::EFS::FileSystem DeletionPolicy: Retain Properties: FileSystemTags: - Key: Name Value: !Sub efs-backup-${AWS::StackName} PerformanceMode: !Sub ${EFSMode} Encrypted: !FindInMap [Map, encryption, !Ref EFSEncryption] MountTarget0: Type: AWS::EFS::MountTarget Properties: FileSystemId: !Sub ${DstEFS} SubnetId: !Select [ 0, !Ref Subnets ] SecurityGroups: - !Sub ${EFSSecurityGroup} MountTarget1: Type: AWS::EFS::MountTarget Properties: FileSystemId: !Sub ${DstEFS} SubnetId: !Select [ 1, !Ref Subnets ] SecurityGroups: - !Sub ${EFSSecurityGroup} # # EC2 resources # [BackupInstanceLaunchConfig, EFSAutoScalingGroup, LifecycleHook] # BackupInstanceLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: ImageId: !GetAtt AMIInfo.Id SecurityGroups: - !Sub ${EFSSecurityGroup} InstanceType: !FindInMap [Map, !Ref "AWS::Region", "InstanceSize"] IamInstanceProfile: !Sub ${InstanceProfile} UserData: # download and run efs-backup script # 12/28/2018 - EFS-21432 - adding retries for downloads Fn::Base64: !Sub - | #!/bin/bash # sudo yum install amazon-ssm-agent -y sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm sudo start amazon-ssm-agent # SIM:V4488716 - 08/03/2018 - Support custom DHCP option # https://github.com/awslabs/efs-backup/issues/1 cat <