# securityGroupIds but where to get the ID from?

**URL:** <https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700>\
**Category:** Serverless Framework\
**Created:** [June 7, 2018, 8:33pm UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700 "2018-06-07T20:33:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![logemann](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/logemann/32/1885_2.png) [@logemann](https://forum.serverless.com/u/logemann)\
**Post date:** [June 7, 2018, 8:33pm UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/1 "2018-06-07T20:33:49Z")

</div>

Hi,

```
apihelloworld:
    handler: hello.world
    vpc:
      securityGroupIds:
        - OkLambdaSG
      subnetIds:
        - OkaydocsPublicSubnet
    events:
      - http:
          path: hello
          method: get
          cors: true

```

i am creating the whole Network Stack (VPC, SecGroups, Routes, etc.) with serverless via Cloudformation Resources section. Now i want to apply the VPC subnet and securityGroups to my lambdas. But with horror i see that you need to supply the Security Group ID which i cant know at this point (it will be created by AWS right?). I only have the internal REF name as seen in the code.

Can it be that one cant make this really dynamic?

thanks  
marc

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 7, 2018, 11:30pm UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/2 "2018-06-07T23:30:07Z")

</div>

You can use `Fn::GetAtt` to retrieve the `GroupId` for a security ground. Something like

```auto
apihelloworld:
    handler: hello.world
    vpc:
      securityGroupIds:
        - { "Fn::GetAtt", ["OkLambdaSG", "GroupId"] }
      subnetIds:
        - OkaydocsPublicSubnet
    events:
      - http:
          path: hello
          method: get
          cors: true

```

---

<div class="post-metadata">

**Author:** ![IvanPodgur](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ivanpodgur/32/6273_2.png) [@IvanPodgur](https://forum.serverless.com/u/IvanPodgur)\
**Post date:** [October 15, 2021, 1:20pm UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/3 "2021-10-15T13:20:47Z")

</div>

You have a little typo, you need `GettAtt ` instead of `GetArr `

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [October 16, 2021, 2:52am UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/4 "2021-10-16T02:52:28Z")

</div>

Thank you. I’ve edited it to update it.

---

<div class="post-metadata">

**Author:** ![ky2ninh](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ky2ninh/32/7054_2.png) [@ky2ninh](https://forum.serverless.com/u/ky2ninh)\
**Post date:** [September 9, 2022, 10:59pm UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/5 "2022-09-09T22:59:18Z")

</div>

When I tried to get security group id for my lambda, I am getting an error:

Incorrect type. Expected “string”

Did it work and then something changed with serverless framework itself?

functions:  
authorizer:  
handler: src/v1/oddc/authorizer.handler  
memorySize: 512  
timeout: 30  
reservedConcurrency: 2  
tracing: PassThrough  
vpc:  
securityGroupIds:  
- { “Fn::GetAtt”, [“AuthorizerLambdaSecurityGroup”, “GroupId”] }  
subnetIds:  
- ${self:custom.PARAMETERS.CoreVpcPrivSubnet1a}  
- ${self:custom.PARAMETERS.CoreVpcPrivSubnet1b}

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [September 15, 2022, 8:29am UTC](https://forum.serverless.com/t/securitygroupids-but-where-to-get-the-id-from/4700/6 "2022-09-15T08:29:27Z")

</div>

Are you sure that `${self:custom.PARAMETERS.CoreVpcPrivSubnet1a}` and `${self:custom.PARAMETERS.CoreVpcPrivSubnet1b}` are set?
