Unable to get VPC YAML working

I am unable to get the YAML correct for the vpc configuration of a function. I have tried multiple iterations of the config lines by adding the vpc section in both the provider: and the function: sections. In both cases, I continue to get errors on deploy during validation of the serverless.yml file. The messages vary between ‘bad indentation of a sequence entry’ and ‘end of the stream or a document separator is expected’ and ‘can not read a block mapping entry; a multiline key may not be an implicit key’. I have followed the documentation as follows:

provider:
  name: aws
  vpc:
    securityGroupIds:
	  - sg-2a88d852
    subnetIds:
	  - subnet-f2c23e96

Does someone have a valid vpc config at the provider or function level? I have tried all manner of spaces after colons and removing spaces. I have wrapped sg and subnets in quotes and dbl-quotes. I have even moved the gd-id up to the save level as the title ‘securityGroupIds: sg-2a88d852’ and this seems to accept the single value, but still errors on the subnetIds. Help…

Hi, for me this works

service: demo-serverless

provider:
  name: aws
  runtime: nodejs4.3
  stage: ${opt:stage}
  region: ${opt:region}
  vpc:
    securityGroupIds:
      - sg-xxxx
    subnetIds:
      - subnet-xxxx
      - subnet-xxxx
      - subnet-xxxx
1 Like

That’s pretty close to what I have in my provider section. I do not have the stage or region sections. I will try and copy/paste yours and edit to add my securitygroup and subnet ids.

Thanks. I changed around the order of items. And now, the package will deploy and properly configure the vpc. I think I will submit this as a bug to the serverless team. Or, if the order of items in the yml is critical, perhaps the docs should call this out. Anyway, thanks for the quick help.