Description: Clouformation stack that spins up the necessary infrastructure for the DataSync demo. **WARNING** This template creates EC2, EFS and related resources. You will be billed for the AWS resources used if you create a stack from this template.
AWSTemplateFormatVersion: "2010-09-09"
Resources:
  datasyncdemovpcEEA15132:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsHostnames: true
      EnableDnsSupport: true
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: datasync-demo-vpc
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/Resource
  datasyncdemovpcpublicsubnetSubnet1Subnet7312A6C4:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.0.0/24
      VpcId:
        Ref: datasyncdemovpcEEA15132
      AvailabilityZone:
        Fn::Select:
          - 0
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: true
      Tags:
        - Key: aws-cdk:subnet-name
          Value: public-subnet
        - Key: aws-cdk:subnet-type
          Value: Public
        - Key: Name
          Value: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1/Subnet
  datasyncdemovpcpublicsubnetSubnet1RouteTableA368646D:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: datasyncdemovpcEEA15132
      Tags:
        - Key: Name
          Value: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1/RouteTable
  datasyncdemovpcpublicsubnetSubnet1RouteTableAssociationEFE63E56:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: datasyncdemovpcpublicsubnetSubnet1RouteTableA368646D
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet1Subnet7312A6C4
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1/RouteTableAssociation
  datasyncdemovpcpublicsubnetSubnet1DefaultRoute8F332121:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: datasyncdemovpcpublicsubnetSubnet1RouteTableA368646D
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId:
        Ref: datasyncdemovpcIGWDDE34EA6
    DependsOn:
      - datasyncdemovpcVPCGW95850C8F
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet1/DefaultRoute
  datasyncdemovpcpublicsubnetSubnet2Subnet30783CA8:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.1.0/24
      VpcId:
        Ref: datasyncdemovpcEEA15132
      AvailabilityZone:
        Fn::Select:
          - 1
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: true
      Tags:
        - Key: aws-cdk:subnet-name
          Value: public-subnet
        - Key: aws-cdk:subnet-type
          Value: Public
        - Key: Name
          Value: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2/Subnet
  datasyncdemovpcpublicsubnetSubnet2RouteTable97DEF932:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: datasyncdemovpcEEA15132
      Tags:
        - Key: Name
          Value: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2/RouteTable
  datasyncdemovpcpublicsubnetSubnet2RouteTableAssociation836CD751:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: datasyncdemovpcpublicsubnetSubnet2RouteTable97DEF932
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet2Subnet30783CA8
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2/RouteTableAssociation
  datasyncdemovpcpublicsubnetSubnet2DefaultRouteD0532ACE:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: datasyncdemovpcpublicsubnetSubnet2RouteTable97DEF932
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId:
        Ref: datasyncdemovpcIGWDDE34EA6
    DependsOn:
      - datasyncdemovpcVPCGW95850C8F
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/public-subnetSubnet2/DefaultRoute
  datasyncdemovpcIGWDDE34EA6:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: datasync-demo-vpc
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/IGW
  datasyncdemovpcVPCGW95850C8F:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: datasyncdemovpcEEA15132
      InternetGatewayId:
        Ref: datasyncdemovpcIGWDDE34EA6
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-demo-vpc/VPCGW
  nfssecuritygroup9883E195:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: DatasyncBlogDemoStack/nfs-security-group
      SecurityGroupEgress:
        - CidrIp: 0.0.0.0/0
          Description: Allow all outbound traffic by default
          IpProtocol: "-1"
      SecurityGroupIngress:
        - CidrIp:
            Fn::GetAtt:
              - datasyncdemovpcEEA15132
              - CidrBlock
          Description:
            Fn::Join:
              - ""
              - - "from "
                - Fn::GetAtt:
                    - datasyncdemovpcEEA15132
                    - CidrBlock
                - :2049
          FromPort: 2049
          IpProtocol: tcp
          ToPort: 2049
      VpcId:
        Ref: datasyncdemovpcEEA15132
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/nfs-security-group/Resource
  efsfsD13DBDD4:
    Type: AWS::EFS::FileSystem
    Properties:
      Encrypted: true
      FileSystemTags:
        - Key: Name
          Value: DataSync Demo
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/efs-fs/Resource
  efsfsEfsMountTarget1D7BFFD17:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId:
        Ref: efsfsD13DBDD4
      SecurityGroups:
        - Fn::GetAtt:
            - nfssecuritygroup9883E195
            - GroupId
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet1Subnet7312A6C4
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/efs-fs/EfsMountTarget1
  efsfsEfsMountTarget206A223FD:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId:
        Ref: efsfsD13DBDD4
      SecurityGroups:
        - Fn::GetAtt:
            - nfssecuritygroup9883E195
            - GroupId
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet2Subnet30783CA8
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/efs-fs/EfsMountTarget2
  mountmachinerole3A8FA5B2:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service:
                Fn::Join:
                  - ""
                  - - ec2.
                    - Ref: AWS::URLSuffix
        Version: "2012-10-17"
      ManagedPolicyArns:
        - Fn::Join:
            - ""
            - - "arn:"
              - Ref: AWS::Partition
              - :iam::aws:policy/AmazonSSMManagedInstanceCore
      RoleName: ec2-MountMachine-Role
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/mount-machine-role/Resource
  mountinstanceInstanceSecurityGroup29E58430:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: DatasyncBlogDemoStack/mount-instance/InstanceSecurityGroup
      SecurityGroupEgress:
        - CidrIp: 0.0.0.0/0
          Description: Allow all outbound traffic by default
          IpProtocol: "-1"
      Tags:
        - Key: Name
          Value: mount-instance
      VpcId:
        Ref: datasyncdemovpcEEA15132
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/mount-instance/InstanceSecurityGroup/Resource
  mountinstanceInstanceProfile5E88C7C5:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Roles:
        - Ref: mountmachinerole3A8FA5B2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/mount-instance/InstanceProfile
  mountinstance06EA6BA0:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone:
        Fn::Select:
          - 0
          - Fn::GetAZs: ""
      IamInstanceProfile:
        Ref: mountinstanceInstanceProfile5E88C7C5
      ImageId:
        Ref: SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter
      InstanceType: t3.medium
      SecurityGroupIds:
        - Fn::GetAtt:
            - mountinstanceInstanceSecurityGroup29E58430
            - GroupId
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet1Subnet7312A6C4
      Tags:
        - Key: Name
          Value: mount-instance
      UserData:
        Fn::Base64: "#!/bin/bash"
    DependsOn:
      - mountmachinerole3A8FA5B2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/mount-instance/Resource
  datasyncagentsecuritygroupA218FE08:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: DatasyncBlogDemoStack/datasync-agent-security-group
      SecurityGroupEgress:
        - CidrIp: 0.0.0.0/0
          Description: Allow all outbound traffic by default
          IpProtocol: "-1"
      SecurityGroupIngress:
        - CidrIp: 0.0.0.0/0
          Description: from 0.0.0.0/0:80
          FromPort: 80
          IpProtocol: tcp
          ToPort: 80
      VpcId:
        Ref: datasyncdemovpcEEA15132
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-agent-security-group/Resource
  datasyncagentinstanceInstanceProfileEDDEB1E7:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Roles:
        - Ref: mountmachinerole3A8FA5B2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-agent-instance/InstanceProfile
  datasyncagentinstanceA1ABF565:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone:
        Fn::Select:
          - 0
          - Fn::GetAZs: ""
      IamInstanceProfile:
        Ref: datasyncagentinstanceInstanceProfileEDDEB1E7
      ImageId:
        Ref: SsmParameterValuedatasyncimportedamiC96584B6F00A464EAD1953AFF4B05118Parameter
      InstanceType: m5.xlarge
      SecurityGroupIds:
        - Fn::GetAtt:
            - datasyncagentsecuritygroupA218FE08
            - GroupId
      SubnetId:
        Ref: datasyncdemovpcpublicsubnetSubnet1Subnet7312A6C4
      Tags:
        - Key: Name
          Value: datasync-agent-instance
      UserData:
        Fn::Base64: "#!/bin/bash"
    DependsOn:
      - mountmachinerole3A8FA5B2
    Metadata:
      aws:cdk:path: DatasyncBlogDemoStack/datasync-agent-instance/Resource
Parameters:
  SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
  SsmParameterValuedatasyncimportedamiC96584B6F00A464EAD1953AFF4B05118Parameter:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Default: datasync-imported-ami
Outputs:
  efsNameoutput:
    Description: The filesystem URL for the EFS
    Value:
      Fn::Join:
        - ""
        - - Ref: efsfsD13DBDD4
          - .efs.
          - Ref: AWS::Region
          - .amazonaws.com

