-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasync_ec2_s3_transfer.yaml
122 lines (114 loc) · 3.36 KB
/
datasync_ec2_s3_transfer.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
SubnetId:
Type: AWS::EC2::Subnet::Id
DataSyncAgentSize:
Type: String
Default: m5.2xlarge
SSHKeyName:
Type: String
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Network Configuration"
Parameters:
- VpcId
- SubnetId
- Label:
default: "DataSync Agent EC2 Instance"
Parameters:
- DataSyncAgentSize
- SSHKeyName
Conditions:
HasSSHKey:
!Not [ !Equals [ !Ref SSHKeyName, '' ] ]
Resources:
DataSyncAgentEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref DataSyncAgentSize
ImageId: !Sub '{{resolve:ssm:/aws/service/datasync/ami}}'
KeyName:
Fn::If:
- HasSSHKey
- !Ref SSHKeyName
- !Ref AWS::NoValue
NetworkInterfaces:
- GroupSet:
- !Ref DataSyncAgentSecurityGroup
AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
DeleteOnTermination: 'true'
SubnetId: !Ref SubnetId
Tags:
- Key: Name
Value: datasync-agent
DataSyncAgentSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: DataSyncAgentSG
GroupDescription: Security group for DataSync agent EC2 instance
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: '0.0.0.0/0'
Description: HTTP access for agent activation
Tags:
- Key: Name
Value: DataSyncAgentSG
DataSyncVpcEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
PrivateDnsEnabled: 'true'
SecurityGroupIds:
- !Ref DataSyncServiceSecurityGroup
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.datasync'
SubnetIds:
- !Ref SubnetId
VpcEndpointType: 'Interface'
VpcId: !Ref VpcId
DataSyncServiceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: DataSyncServiceSG
GroupDescription: Security group for DataSync VPC endpoint and task ENIs
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 1024
ToPort: 1064
SourceSecurityGroupId: !GetAtt DataSyncAgentSecurityGroup.GroupId
Description: Ingress from DataSync agent
- IpProtocol: tcp
FromPort: 443
ToPort: 443
SourceSecurityGroupId: !GetAtt DataSyncAgentSecurityGroup.GroupId
Description: Ingress from DataSync agent
Tags:
- Key: Name
Value: DataSyncServiceSG
DataSyncNfsServerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: DataSyncNfsServerSG
GroupDescription: Security group for DataSync NFS server
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 2049
ToPort: 2049
SourceSecurityGroupId: !GetAtt DataSyncAgentSecurityGroup.GroupId
Description: Ingress from DataSync agent
- IpProtocol: udp
FromPort: 2049
ToPort: 2049
SourceSecurityGroupId: !GetAtt DataSyncAgentSecurityGroup.GroupId
Description: Ingress from DataSync agent
Tags:
- Key: Name
Value: DataSyncNfsServerSG