Skip to content

vpc.securityGroupIds should support CF intrinsic function #10058

@lephuongbg

Description

@lephuongbg

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest version?

  • Yes, I'm using the latest version

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

We're currently using If function in vpc.securityGroupIds to conditionally add/remove a security group. Serverless is currently throwing warning as below:

Configuration warning at 'provider.vpc.securityGroupIds[3]': unsupported object format

Service configuration (serverless.yml) content

service: fmi-stack-api

provider:
  name: aws
  runtime: python3.8
  stage: ${opt:stage,'dev'}
  vpc:
    securityGroupIds:
      - ${cf:stack-redis-${self:provider.stage}.SecurityGroup}
      - ${cf:stack-postgres-${self:provider.stage}.SecurityGroup}
      - ${cf:stack-elasticsearch-${self:provider.stage}.SecurityGroup}
      - !If [MailhogUsed, "${cf:stack-mailhog-${self:provider.stage}.SecurityGroup, ''}", !Ref 'AWS::NoValue']
    subnetIds:
      - ${cf:stack-network-${self:provider.stage}.PrivateSubnet1}
      - ${cf:stack-network-${self:provider.stage}.PrivateSubnet2}

functions:
  task:
    handler: task_handler.handler
resources:
  Conditions:
    MailhogUsed:
      Fn::Not:
      - Fn::Equals:
        - ${cf:stack-mailhog-${self:provider.stage}.SecurityGroup, ''}
        - ''

Command name and used flags

sls deploy

Command output

N/A

Environment information

Framework Core: 2.61.0 (local)
Plugin: 5.4.5
SDK: 4.3.0
Components: 3.17.1

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions