How to reference a new security group in function definition

Hi all,

With serverless 1.0b2, I’m trying to create a security group with cloudformation and attach this SG to my lambda function (for the VPC integration feature). I can already create the new security group, but how would I reference it in my function definition given that I don’t know its id/name until it is deployed?

This is my custom resource definition in serverless.yml (sorry, the indentation is not preserved for some reason):
resources: Resources: LambdaSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: StealthMonitorSecurityGroup SecurityGroupEgress: - IpProtocol: -1 CidrIp: SecurityGroupIngress: - IpProtocol: -1 CidrIp: VpcId: ${VpcId}


Nevermind, I found the answer.

For anyone else interested, this is how I’ve done it (again, the indentation is wrong):
provider: name: aws runtime: nodejs4.3 vpc: securityGroupIds: - Ref: LambdaSecurityGroup

The 'LambdaSecurityGroup" reference name comes from my custom resource name


are you able to share the cloudformation template you used to create your security group in serverless?