Skip to content

How to configure security groups in Load Balancer Web Service #2420

@shgtkshruch

Description

@shgtkshruch

Hi, there.
I would like to set my custom security group to ECS tasks, so I add network configuration to manifest.yml as documented here.

name: rails
type: Load Balanced Web Service
...
network:
  vpc:
    security_groups: ['sg-09ce2df3852b84be9']

And deploy these commands.

$ copilot version
version: v1.7.0, built for darwin

$ copilot svc deploy -e dev -n rails 

In AWS Management Console, sg-09ce2df3852b84be9 is not set to ECS tasks. Only the security group set with Copilot by default is configured for the ECS tasks.

スクリーンショット 2021-06-04 23 19 17

It seemed that the security group set in manifest.yml was not set in the CloudFormation template as well.

$ copilot svc package -e dev -n rails
...
Service:
    Metadata:
      'aws:copilot:description': 'An ECS service to run and maintain your tasks in the environment cluster'
    Type: AWS::ECS::Service
    DependsOn: WaitUntilListenerRuleIsCreated
    Properties:
      Cluster:
        Fn::ImportValue:
          !Sub '${AppName}-${EnvName}-ClusterId'
      TaskDefinition: !Ref TaskDefinition
      DesiredCount: !Ref TaskCount
      DeploymentConfiguration:
        DeploymentCircuitBreaker:
          Enable: true
          Rollback: true
        MinimumHealthyPercent: 100
        MaximumPercent: 200
      PropagateTags: SERVICE
      EnableExecuteCommand: true
      LaunchType: FARGATE
      NetworkConfiguration:
        AwsvpcConfiguration:
          AssignPublicIp: ENABLED
          Subnets:
            - Fn::Select:
              - 0
              - Fn::Split:
                - ','
                - Fn::ImportValue: !Sub '${AppName}-${EnvName}-PublicSubnets'
            - Fn::Select:
              - 1
              - Fn::Split:
                - ','
                - Fn::ImportValue: !Sub '${AppName}-${EnvName}-PublicSubnets'
          SecurityGroups:
            - Fn::ImportValue: !Sub '${AppName}-${EnvName}-EnvironmentSecurityGroup'
            - Fn::GetAtt: [AddonsStack, Outputs.railsclusterSecurityGroup]
...

Any suggestion would be appreciated.
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugIssues that are bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions