Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"public" option not working #17

Open
eschneider1271 opened this issue Aug 5, 2020 · 2 comments
Open

"public" option not working #17

eschneider1271 opened this issue Aug 5, 2020 · 2 comments

Comments

@eschneider1271
Copy link

Hi,

I can't seem to get the public option working.
I tried moving this option out of the services array and into the options context, which helped.
Now, the generated CloudFormation in my .serverless directory correctly sets AssignPublicIp as desired.
However, I'm hitting the following validation error on deployment:

Serverless: [AWS cloudformation 400 0.528s 0 retries] validateTemplate({ TemplateURL:
   'https://.../...-2020-08-05T22:26:46.286Z/compiled-cloudformation-template.json' })
 
  Error --------------------------------------------------
 
  Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [slsFargateTestContainerSecurityG] in the Resources block of the template
      at provider.request.catch.error (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13)

It looks like a required security group is not being created?

Here's my full template:

service: slsFargate

provider:
  name: aws
  profile: default
  stage: ${opt:stage, 'test'}
  timeout: 300
  region: us-east-1

plugins:
  - serverless-fargate-plugin

custom:
  fargate:
    - clusterName: Test
      vpc:
        vpcId: vpc-xxx
        subnetIds:
        - subnet-xxx
        - subnet-xxx
        securityGroupIds:
        - sg-xxx
      public: true
      services:
      - name: php-apache-app
        cpu: 512
        memory: 1024
        port: 80
        healthCheckUri: /
        healthCheckInterval: 6
        image: "xxx.dkr.ecr.us-east-1.amazonaws.com/xx:latest"
        autoScale:
          min: 1
          max: 10
          cooldownIn: 30
          cooldownOut: 60
          metric: ECSServiceAverageCPUUtilization
          targetValue: 75
        environment:
          PRODUCTION: false
        protocols:
        - protocol: HTTP

Any ideas? Thanks.

@spbarber
Copy link

spbarber commented Jul 8, 2021

Hi @eschneider1271,

I ran into the same problem but had to clone the repo and modify the code to get it working correctly.

The following function needed updating in the Cluster class:

public isPublic(): boolean {
    return this.options.services[0].public;
}

Add a public property to the IServiceOptions:

export interface IServiceOptions {
    name: string;
    cpu: number;
    memory: number;
    public: boolean;

I tested it this week and works as it was intended to do so.

@gwdp
Copy link
Contributor

gwdp commented Jul 8, 2021

Please, check #26, this issue has been fixed on the active repository since last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants