# How to reference a new security group in function definition

**URL:** <https://forum.serverless.com/t/how-to-reference-a-new-security-group-in-function-definition/207>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [August 29, 2016, 11:42pm UTC](https://forum.serverless.com/t/how-to-reference-a-new-security-group-in-function-definition/207 "2016-08-29T23:42:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fruffin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/fruffin/32/929_2.png) [@fruffin](https://forum.serverless.com/u/fruffin)\
**Post date:** [August 29, 2016, 11:42pm UTC](https://forum.serverless.com/t/how-to-reference-a-new-security-group-in-function-definition/207/1 "2016-08-29T23:42:59Z")

</div>

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: 0.0.0.0/0 SecurityGroupIngress: - IpProtocol: -1 CidrIp: 0.0.0.0/0 VpcId: ${VpcId}`

Thanks!

---

<div class="post-metadata">

**Author:** ![fruffin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/fruffin/32/929_2.png) [@fruffin](https://forum.serverless.com/u/fruffin)\
**Post date:** [August 29, 2016, 11:55pm UTC](https://forum.serverless.com/t/how-to-reference-a-new-security-group-in-function-definition/207/2 "2016-08-29T23:55:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![corydorning](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/corydorning/32/4350_2.png) [@corydorning](https://forum.serverless.com/u/corydorning)\
**Post date:** [September 15, 2020, 3:20pm UTC](https://forum.serverless.com/t/how-to-reference-a-new-security-group-in-function-definition/207/3 "2020-09-15T15:20:51Z")

</div>

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