OMERO-cloudformation-templates/OMEROonECS_ALBNLBwithTLS_RW.yaml [113:349]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mappings:
  AWSRegionToAMI:
    us-east-1:
      AMIID: ami-01783fbb0757adced
    us-east-2:
      AMIID: ami-0adc4758ea76442e2
    us-west-1:
      AMIID: ami-00becdb34b62bf459
    us-west-2:
      AMIID: ami-09f043c293281ecd4
    ap-northeast-1:
      AMIID: ami-04bbc04d168366d27
    ap-northeast-2:
      AMIID: ami-0273b23020d7a59de
    ap-south-1:
      AMIID: ami-000e4b3f0c9f06ffb
    ap-southeast-1:
      AMIID: ami-071fbc655b2398016
    ap-southeast-2:
      AMIID: ami-032edebfa34883542
    ca-central-1:
      AMIID: ami-092b596d9b942c4f8
    eu-central-1:
      AMIID: ami-097b8c9927f9a27bc
    eu-north-1:
      AMIID: ami-09666749b685f34d5
    eu-west-1:
      AMIID: ami-015b1508a2ff2c65a
    eu-west-2:
      AMIID: ami-0141564f07476504d
    eu-west-3:
      AMIID: ami-04cb3664fdfc392bd
    sa-east-1:
      AMIID: ami-003a04511c336560c

  RegionELBAccountIdMap:
    us-east-1:
      AccountId: '127311923021'
    us-west-1:
      AccountId: '027434742980'
    us-west-2:
      AccountId: '797873946194'
    eu-west-1:
      AccountId: '156460612806'
    ap-northeast-1:
      AccountId: '582318560864'
    ap-northeast-2:
      AccountId: '600734575887'
    ap-southeast-1:
      AccountId: '114774131450'
    ap-southeast-2:
      AccountId: '783225319266'
    ap-south-1:
      AccountId: '718504428378'
    us-east-2:
      AccountId: '033677994240'
    sa-east-1:
      AccountId: '507241528517'
    cn-north-1:
      AccountId: '638102146993'
    eu-central-1:
      AccountId: '054676820928'

Resources:
  CloudMap:
    Type: AWS::ServiceDiscovery::PrivateDnsNamespace
    Properties:
      Description: Service Map for OMERO ECS deployment
      Name: !Sub ${AWS::StackName}.ecscloudmap.org
      Vpc: !Ref VPCID
  OmerowebServiceDiscoveryEntry:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Description: '"omeroweb" service discovery entry in Cloud Map'
      DnsConfig:
        DnsRecords:
          - TTL: 60
            Type: A
        RoutingPolicy: MULTIVALUE
      HealthCheckCustomConfig:
        FailureThreshold: 1
      Name: omeroweb
      NamespaceId: !Ref 'CloudMap'
  OmeroserverServiceDiscoveryEntry:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Description: '"omeroserver" service discovery entry in Cloud Map'
      DnsConfig:
        DnsRecords:
          - TTL: 60
            Type: A
        RoutingPolicy: MULTIVALUE
      HealthCheckCustomConfig:
        FailureThreshold: 1
      Name: omeroserver
      NamespaceId: !Ref 'CloudMap'
  
  OMEROECSCluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: !Sub ${AWS::StackName}-OMEROECSCluster
      ClusterSettings:
        - Name: containerInsights
          Value:  enabled
      Tags:
        - Key: project
          Value: omero-on-aws
  OMEROLoadBalancer:
    DependsOn:
      - LBAccessLogBucket
      - LBAccessLogBucketPolicy
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      LoadBalancerAttributes:
        - Key: load_balancing.cross_zone.enabled
          Value: "true"
      Scheme: internet-facing
      Subnets:
        - !Ref 'PublicSubnet1Id'
        - !Ref 'PublicSubnet2Id'
      SecurityGroups:
        - !Ref LBSecurityGroup
      Tags:
        - Key: project
          Value: omero-on-aws
      Type: application
      LoadBalancerAttributes:
        - Key: access_logs.s3.enabled
          Value: true
        - Key: access_logs.s3.bucket
          Value: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
  OMERONetworkLoadBalancer:
    DependsOn:
      - LBAccessLogBucket
      - LBAccessLogBucketPolicy
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Scheme: internet-facing
      Subnets:
        - !Ref 'PublicSubnet1Id'
        - !Ref 'PublicSubnet2Id'
      Tags:
        - Key: project
          Value: omero-on-aws
      Type: network
      LoadBalancerAttributes:
        - Key: access_logs.s3.enabled
          Value: true
        - Key: access_logs.s3.bucket
          Value: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
  LBAccessLogBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256
  LBAccessLogBucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties: 
      Bucket: !Ref LBAccessLogBucket
      PolicyDocument:
        Statement:
          - Action:
              - 's3:PutObject'
            Effect: Allow
            Resource: 
              - !Sub '${LBAccessLogBucket.Arn}/*'
            Principal: 
              AWS: !FindInMap [RegionELBAccountIdMap, !Ref 'AWS::Region', AccountId]
          - Action:
              - 's3:PutObject'
            Effect: Allow
            Resource: 
              - !Sub '${LBAccessLogBucket.Arn}/*'
            Principal: 
              Service: delivery.logs.amazonaws.com
            Condition:
              StringEquals:
                s3:x-amz-acl: bucket-owner-full-control
          - Action:
              - 's3:GetBucketAcl'
            Effect: Allow
            Resource: 
              - !Sub ${LBAccessLogBucket.Arn}
            Principal: 
              Service: delivery.logs.amazonaws.com
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub /ecs/omero/${AWS::StackName}
  
  MountTarget:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId: !Ref EFSFileSystem
      SubnetId: !Ref PrivateSubnet1Id
      SecurityGroups:
        - !Ref EFSSecurityGroup
  NFSAccessPoint:
    Type: AWS::EFS::AccessPoint
    Properties: 
      FileSystemId: !Ref EFSFileSystem
      PosixUser:
        Gid: "0"
        Uid: "0"
      RootDirectory:
        Path: "/"

  OmeroserverService:
    Type: AWS::ECS::Service
    DependsOn:
      - OMERONetworkLoadBalancer
      - OmeroserverTaskDefinition
      - OmeroserverTCP4064Listener
      - OmeroserverTCP4063Listener
    Properties:
      Cluster: !Ref 'OMEROECSCluster'
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 100
      DeploymentController:
        Type: ECS
      DesiredCount: 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



OMERO-cloudformation-templates/OMEROonECS_ALBNLBwithTLS_RW_StorageGateway.yaml [113:349]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mappings:
  AWSRegionToAMI:
    us-east-1:
      AMIID: ami-01783fbb0757adced
    us-east-2:
      AMIID: ami-0adc4758ea76442e2
    us-west-1:
      AMIID: ami-00becdb34b62bf459
    us-west-2:
      AMIID: ami-09f043c293281ecd4
    ap-northeast-1:
      AMIID: ami-04bbc04d168366d27
    ap-northeast-2:
      AMIID: ami-0273b23020d7a59de
    ap-south-1:
      AMIID: ami-000e4b3f0c9f06ffb
    ap-southeast-1:
      AMIID: ami-071fbc655b2398016
    ap-southeast-2:
      AMIID: ami-032edebfa34883542
    ca-central-1:
      AMIID: ami-092b596d9b942c4f8
    eu-central-1:
      AMIID: ami-097b8c9927f9a27bc
    eu-north-1:
      AMIID: ami-09666749b685f34d5
    eu-west-1:
      AMIID: ami-015b1508a2ff2c65a
    eu-west-2:
      AMIID: ami-0141564f07476504d
    eu-west-3:
      AMIID: ami-04cb3664fdfc392bd
    sa-east-1:
      AMIID: ami-003a04511c336560c

  RegionELBAccountIdMap:
    us-east-1:
      AccountId: '127311923021'
    us-west-1:
      AccountId: '027434742980'
    us-west-2:
      AccountId: '797873946194'
    eu-west-1:
      AccountId: '156460612806'
    ap-northeast-1:
      AccountId: '582318560864'
    ap-northeast-2:
      AccountId: '600734575887'
    ap-southeast-1:
      AccountId: '114774131450'
    ap-southeast-2:
      AccountId: '783225319266'
    ap-south-1:
      AccountId: '718504428378'
    us-east-2:
      AccountId: '033677994240'
    sa-east-1:
      AccountId: '507241528517'
    cn-north-1:
      AccountId: '638102146993'
    eu-central-1:
      AccountId: '054676820928'

Resources:
  CloudMap:
    Type: AWS::ServiceDiscovery::PrivateDnsNamespace
    Properties:
      Description: Service Map for OMERO ECS deployment
      Name: !Sub ${AWS::StackName}.ecscloudmap.org
      Vpc: !Ref VPCID
  OmerowebServiceDiscoveryEntry:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Description: '"omeroweb" service discovery entry in Cloud Map'
      DnsConfig:
        DnsRecords:
          - TTL: 60
            Type: A
        RoutingPolicy: MULTIVALUE
      HealthCheckCustomConfig:
        FailureThreshold: 1
      Name: omeroweb
      NamespaceId: !Ref 'CloudMap'
  OmeroserverServiceDiscoveryEntry:
    Type: AWS::ServiceDiscovery::Service
    Properties:
      Description: '"omeroserver" service discovery entry in Cloud Map'
      DnsConfig:
        DnsRecords:
          - TTL: 60
            Type: A
        RoutingPolicy: MULTIVALUE
      HealthCheckCustomConfig:
        FailureThreshold: 1
      Name: omeroserver
      NamespaceId: !Ref 'CloudMap'
  
  OMEROECSCluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: !Sub ${AWS::StackName}-OMEROECSCluster
      ClusterSettings:
        - Name: containerInsights
          Value:  enabled
      Tags:
        - Key: project
          Value: omero-on-aws
  OMEROLoadBalancer:
    DependsOn:
      - LBAccessLogBucket
      - LBAccessLogBucketPolicy
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      LoadBalancerAttributes:
        - Key: load_balancing.cross_zone.enabled
          Value: "true"
      Scheme: internet-facing
      Subnets:
        - !Ref 'PublicSubnet1Id'
        - !Ref 'PublicSubnet2Id'
      SecurityGroups:
        - !Ref LBSecurityGroup
      Tags:
        - Key: project
          Value: omero-on-aws
      Type: application
      LoadBalancerAttributes:
        - Key: access_logs.s3.enabled
          Value: true
        - Key: access_logs.s3.bucket
          Value: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
  OMERONetworkLoadBalancer:
    DependsOn:
      - LBAccessLogBucket
      - LBAccessLogBucketPolicy
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Scheme: internet-facing
      Subnets:
        - !Ref 'PublicSubnet1Id'
        - !Ref 'PublicSubnet2Id'
      Tags:
        - Key: project
          Value: omero-on-aws
      Type: network
      LoadBalancerAttributes:
        - Key: access_logs.s3.enabled
          Value: true
        - Key: access_logs.s3.bucket
          Value: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
  LBAccessLogBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Join
            - '-'
            - - !Ref LBAccessLogBucketName
              - !Ref Namespace
              - !Ref AWS::AccountId
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256
  LBAccessLogBucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties: 
      Bucket: !Ref LBAccessLogBucket
      PolicyDocument:
        Statement:
          - Action:
              - 's3:PutObject'
            Effect: Allow
            Resource: 
              - !Sub '${LBAccessLogBucket.Arn}/*'
            Principal: 
              AWS: !FindInMap [RegionELBAccountIdMap, !Ref 'AWS::Region', AccountId]
          - Action:
              - 's3:PutObject'
            Effect: Allow
            Resource: 
              - !Sub '${LBAccessLogBucket.Arn}/*'
            Principal: 
              Service: delivery.logs.amazonaws.com
            Condition:
              StringEquals:
                s3:x-amz-acl: bucket-owner-full-control
          - Action:
              - 's3:GetBucketAcl'
            Effect: Allow
            Resource: 
              - !Sub ${LBAccessLogBucket.Arn}
            Principal: 
              Service: delivery.logs.amazonaws.com
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub /ecs/omero/${AWS::StackName}
  
  MountTarget:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId: !Ref EFSFileSystem
      SubnetId: !Ref PrivateSubnet1Id
      SecurityGroups:
        - !Ref EFSSecurityGroup
  NFSAccessPoint:
    Type: AWS::EFS::AccessPoint
    Properties: 
      FileSystemId: !Ref EFSFileSystem
      PosixUser:
        Gid: "0"
        Uid: "0"
      RootDirectory:
        Path: "/"

  OmeroserverService:
    Type: AWS::ECS::Service
    DependsOn:
      - OMERONetworkLoadBalancer
      - OmeroserverTaskDefinition
      - OmeroserverTCP4064Listener
      - OmeroserverTCP4063Listener
    Properties:
      Cluster: !Ref 'OMEROECSCluster'
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 100
      DeploymentController:
        Type: ECS
      DesiredCount: 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



