HostedZoneName:
"Fn::Sub":
- "${HostedZoneName}."
- { HostedZoneName: !ImportValue peoplesoft-route53-dns }
Name:
"Fn::Sub":
- "sftp.peoplesoft-sftp-hub.${HostedZoneName}."
- { HostedZoneName: !ImportValue peoplesoft-route53-dns }
Type: CNAME
TTL: '900'
ResourceRecords:
- !If [YesEips, !GetAtt SftpNetworkLoadBalancerEip.DNSName, !GetAtt SftpNetworkLoadBalancer.DNSName]
EcsLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "${UppercaseSFTPEnv}-SFTP-Hub-LG"
RetentionInDays: 30
EcsInstanceLc:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: !Ref EcsImageId
InstanceType: !Ref EcsInstanceType
AssociatePublicIpAddress: false
IamInstanceProfile: !Ref EnvInstanceProfile
KeyName: !Ref KeyName
SecurityGroups:
- !Ref InstanceSecurityGroup
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-ELMEFSSG"
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-HREFSSG"
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-SAEncryptedEFSSG"
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-SshSg"
BlockDeviceMappings:
- DeviceName: "/dev/xvdcz"
Ebs:
VolumeSize: "22"
VolumeType: "gp2"
UserData:
Fn::Base64: !Sub |
echo ECS_CLUSTER=${UppercaseSFTPEnv}SFTP >> /etc/ecs/ecs.config
EcsInstanceAsg:
Type: AWS::AutoScaling::AutoScalingGroup
DependsOn: EcsCluster
Properties:
VPCZoneIdentifier:
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-PrivSubNet1"
- Fn::ImportValue:
!Sub "${SecurityGroupCloudFormationName}-PrivSubNet2"
LaunchConfigurationName: !Ref EcsInstanceLc
MinSize: '0'
MaxSize: !If [ThisIsProd,"2","1"]
DesiredCapacity: !If [ThisIsProd,"2","1"]
TargetGroupARNs:
- !Ref SftpELBV2Tg
Tags:
- Key: Name
Value: !Sub "ECS Instance - ${AWS::StackName}"
PropagateAtLaunch: 'true'
- Key: Description
Value: "This instance is the part of the Auto Scaling group which was created through CloudFormation"
PropagateAtLaunch: 'true'
- Key: service
Value: !Ref TagService
PropagateAtLaunch: 'true'
- Key: environment
Value: !Sub "${LowercasePillar}-sftp-hub"
PropagateAtLaunch: 'true'
- Key: contactnetid
Value: !Ref TagContactNetid
PropagateAtLaunch: 'true'
- Key: accountnumber
Value: !Ref TagAccountNumber
PropagateAtLaunch: 'true'
- Key: ticketnumber
Value: !Ref "TagTicketNumber"
PropagateAtLaunch: 'true'
- Key: subaccount
Value: !Ref TagSubAccount
PropagateAtLaunch: 'true'
EcsCluster:
Type: "AWS::ECS::Cluster"
Properties:
ClusterName: !Sub "${UppercaseSFTPEnv}SFTP"
EcsTask:
Type: "AWS::ECS::TaskDefinition"
Properties:
Family: !Sub "${UppercaseSFTPEnv}-SFTP"
NetworkMode: "bridge"
ContainerDefinitions:
- Name: !Sub "${UppercaseSFTPEnv}-SFTP"
Essential: "true"
Image: !Ref DockerImage
PortMappings:
- HostPort: "0"
ContainerPort: "22"
Protocol: "tcp"
Hostname: !Sub "${LowercasePillar}-sftp"
Cpu: "200"
MemoryReservation: "512"
Privileged: "true"
Environment:
- Name: "SFTP_ENV"
Value: !Sub "${UppercaseSFTPEnv}"
- Name: "SFTP_MOUNTS"
Value:
Fn::Sub:
- "${ThisEFSID}.efs.${AWS::Region}.amazonaws.com:/=${MountPath}"
- ThisEFSID:
Fn::FindInMap: [EFSID,!Ref "AWS::AccountId",!Ref "LowercasePillar"]
MountPath:
Fn::If: [OverridePath, !Ref OverrideMountPath, !Sub "/mosaic/${UppercaseSFTPEnv}"]
- Name: "SNS_NOTIFICATION_TOPIC"
Value: !ImportValue fdn-logging-alarm-topic
- Name: "BackupSourcePath"
Value:
Fn::Sub:
- "${MountPath}"
- MountPath:
Fn::If: [OverridePath, !Ref OverrideMountPath, !Sub "/mosaic/${UppercaseSFTPEnv}"]
- Name: "S3DRBackupURI"
Value: !Sub "s3://${DRS3Bucket}/${LowercasePillar}${LoggingLabel}"
LogConfiguration:
LogDriver: "awslogs"
Options:
awslogs-group: !Ref "EcsLogGroup"
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: "SFTP-HUB"
SFTP Hub CloudFormation Deployment
This CloudFormation template will build an ECS stack to support a central SFTP server with multiple EFS systems mounted.