Skip to content

VpcConfig support#64

Merged
DeviaVir merged 2 commits intomotdotla:masterfrom
DeviaVir:vpc-config-support
Apr 8, 2016
Merged

VpcConfig support#64
DeviaVir merged 2 commits intomotdotla:masterfrom
DeviaVir:vpc-config-support

Conversation

@DeviaVir
Copy link
Collaborator

VpcConfig support:

Use AWS API 2015-03-31:

  • Check if the function exists, if it does update else create new
  • This API provides compatibility with VpcConfig

Fixes #61

- http://docs.aws.amazon.com/lambda/latest/dg/API_VpcConfig.html
- http://docs.aws.amazon.com/lambda/latest/dg/vpc.html
This allows users to place their Lambda functions in specific subnets with specific security groups.
@DeviaVir DeviaVir force-pushed the vpc-config-support branch from b78caa9 to 53e1df2 Compare March 25, 2016 12:14
@DeviaVir
Copy link
Collaborator Author

Test results:

New function:

~ node-lambda/bin/node-lambda deploy
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Reading zip file to memory
=> Uploading zip file to AWS Lambda us-west-2 with parameters:
{ FunctionName: 'NodeFunction-development',
  Code: { ZipFile: <Buffer 50 4b 03 04 14 00 00 00 08 00 ba 69 79 48 6a 00 88 6d b2 00 00 00 04 18 00 00 09 00 1c 00 2e 44 53 5f 53 74 6f 72 65 55 54 09 00 03 7f 2b f5 56 7f 2b ... > },
  Handler: 'index.handler',
  Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
  Runtime: 'nodejs',
  Description: 'This can be safely removed at any time.',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig: {} }
=> Zip file(s) done uploading. Results follow:
[ { FunctionName: 'NodeFunction-development',
    FunctionArn: 'arn:aws:lambda:us-west-2:xxxxxxxxxxxx:function:NodeFunction-development',
    Runtime: 'nodejs',
    Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
    Handler: 'index.handler',
    CodeSize: 10296,
    Description: 'This can be safely removed at any time.',
    Timeout: 3,
    MemorySize: 128,
    LastModified: '2016-03-25T12:13:53.504+0000',
    CodeSha256: 'xxxxxxxxxxxx=',
    Version: '$LATEST' } ]

Update:

~ node-lambda/bin/node-lambda deploy
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Reading zip file to memory
=> Uploading zip file to AWS Lambda us-west-2 with parameters:
{ FunctionName: 'NodeFunction-development',
  Code: { ZipFile: <Buffer 50 4b 03 04 14 00 00 00 08 00 d1 69 79 48 6a 00 88 6d b2 00 00 00 04 18 00 00 09 00 1c 00 2e 44 53 5f 53 74 6f 72 65 55 54 09 00 03 aa 2b f5 56 aa 2b ... > },
  Handler: 'index.handler',
  Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
  Runtime: 'nodejs',
  Description: 'This can be safely removed at any time.',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig: {} }
=> Zip file(s) done uploading. Results follow:
[ { FunctionName: 'NodeFunction-development',
    FunctionArn: 'arn:aws:lambda:us-west-2:xxxxxxxxxxxx:function:NodeFunction-development',
    Runtime: 'nodejs',
    Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
    Handler: 'index.handler',
    CodeSize: 10300,
    Description: 'This can be safely removed at any time.',
    Timeout: 3,
    MemorySize: 128,
    LastModified: '2016-03-25T12:14:37.224+0000',
    CodeSha256: 'xxxxxxxxxxxx=',
    Version: '$LATEST' } ]

Create with VpcConfig:

~ node-lambda/bin/node-lambda deploy
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Reading zip file to memory
=> Uploading zip file to AWS Lambda us-west-2 with parameters:
{ FunctionName: 'NodeFunc-development',
  Code: { ZipFile: <Buffer 50 4b 03 04 14 00 00 00 08 00 b9 6a 79 48 6a 00 88 6d b2 00 00 00 04 18 00 00 09 00 1c 00 2e 44 53 5f 53 74 6f 72 65 55 54 09 00 03 5d 2d f5 56 5d 2d ... > },
  Handler: 'index.handler',
  Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
  Runtime: 'nodejs',
  Description: 'This can be safely removed at any time.',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig:
   { SubnetIds: [ 'subnet-00000000', 'subnet-00000000', 'subnet-00000000' ],
     SecurityGroupIds: [ 'sg-00000000' ] } }
=> Zip file(s) done uploading. Results follow:
[ { FunctionName: 'NodeFunc-development',
    FunctionArn: 'arn:aws:lambda:us-west-2:xxxxxxxxxxxx:function:NodeFunc-development',
    Runtime: 'nodejs',
    Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
    Handler: 'index.handler',
    CodeSize: 10359,
    Description: 'This can be safely removed at any time.',
    Timeout: 3,
    MemorySize: 128,
    LastModified: '2016-03-25T12:21:51.280+0000',
    CodeSha256: 'xxxxxxxxxxxx=',
    Version: '$LATEST',
    VpcConfig:
     { SubnetIds: [Object],
       SecurityGroupIds: [Object],
       VpcId: 'vpc-00000000' } } ]

Update with VpcConfig:

~ node-lambda/bin/node-lambda deploy
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Reading zip file to memory
=> Uploading zip file to AWS Lambda us-west-2 with parameters:
{ FunctionName: 'NodeFunc-development',
  Code: { ZipFile: <Buffer 50 4b 03 04 14 00 00 00 08 00 74 6a 79 48 6a 00 88 6d b2 00 00 00 04 18 00 00 09 00 1c 00 2e 44 53 5f 53 74 6f 72 65 55 54 09 00 03 db 2c f5 56 db 2c ... > },
  Handler: 'index.handler',
  Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
  Runtime: 'nodejs',
  Description: 'This can be safely removed at any time.',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig:
   { SubnetIds: [ 'subnet-00000000', 'subnet-00000000', 'subnet-00000000' ],
     SecurityGroupIds: [ 'sg-00000000' ] } }
=> Zip file(s) done uploading. Results follow:
[ { FunctionName: 'NodeFunc-development',
    FunctionArn: 'arn:aws:lambda:us-west-2:xxxxxxxxxxxx:function:NodeFunction-development',
    Runtime: 'nodejs',
    Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_basic_vpc_execution',
    Handler: 'index.handler',
    CodeSize: 10360,
    Description: 'This can be safely removed at any time.',
    Timeout: 3,
    MemorySize: 128,
    LastModified: '2016-03-25T12:19:43.028+0000',
    CodeSha256: 'xxxxxxxxxxxx=',
    Version: '$LATEST',
    VpcConfig:
     { SubnetIds: [Object],
       SecurityGroupIds: [Object],
       VpcId: 'vpc-00000000' } } ]

@DeviaVir DeviaVir force-pushed the vpc-config-support branch from 53e1df2 to c5f99fd Compare March 25, 2016 12:26
- Check if the function exists, if it does update else create new
- This API provides compatibility with VpcConfig
@adamlc
Copy link

adamlc commented Apr 5, 2016

👍

@DeviaVir
Copy link
Collaborator Author

DeviaVir commented Apr 8, 2016

ping @motdotla

@DeviaVir DeviaVir merged commit ae69e4a into motdotla:master Apr 8, 2016
@demian85
Copy link

Can someone please explain how to set the VPC ID? There is no option for that...

@DeviaVir DeviaVir deleted the vpc-config-support branch February 18, 2019 18:06
@DeviaVir
Copy link
Collaborator Author

@demian85 It works by setting the VPC's subnets and security groups:

AWS_VPC_SUBNETS=subnet-xxx,subnet-yyy
AWS_VPC_SECURITY_GROUPS=sg-xxx,sg-yyy

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

Successfully merging this pull request may close these issues.

3 participants