AWSTemplateFormatVersion: 2010-09-09
Description: IAM Role and policies for Sedai Integration - ECS Autoscaling
Resources:
  SedaiIntegrationAppAutoScalingRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: sedai-integration-application-autoscaling-role
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - application-autoscaling.amazonaws.com
            Action:
              - sts:AssumeRole
      Path: "/"
  SedaiIntegrationAppAutoScalingPolicy:
    Type: "AWS::IAM::ManagedPolicy"
    Properties:
      ManagedPolicyName: sedai-integration-application-autoscaling-role
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
              - "application-autoscaling:*"
              - "ecs:DescribeServices"
              - "ecs:UpdateService"
              - "cloudwatch:DescribeAlarms"
              - "cloudwatch:PutMetricAlarm"
              - "cloudwatch:DeleteAlarms"
              - "cloudwatch:DescribeAlarmHistory"
              - "cloudwatch:DescribeAlarmsForMetric"
              - "cloudwatch:GetMetricStatistics"
              - "cloudwatch:ListMetrics"
              - "cloudwatch:DisableAlarmActions"
              - "cloudwatch:EnableAlarmActions"
              - "iam:CreateServiceLinkedRole"
              - "sns:CreateTopic"
              - "sns:Subscribe"
              - "sns:Get*"
              - "sns:List*"
            Resource: "*"
      Roles:
        - Ref: "SedaiIntegrationAppAutoScalingRole"
Outputs:
  SedaiIntegrationAppAutoScalingRoleName:
    Description: Sedai Role Name
    Value:
      Ref: SedaiIntegrationAppAutoScalingRole
  SedaiIntegrationAppAutoScalingRoleArn:
    Description: Sedai Role Arn
    Value:
      Fn::GetAtt: [SedaiIntegrationAppAutoScalingRole, Arn]
