Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The provided execution role does not have permissions to call CreateNetworkInterface on EC2... #16

Open
rlyle opened this issue Nov 23, 2020 · 3 comments

Comments

@rlyle
Copy link

rlyle commented Nov 23, 2020

Hitting the following error when trying to create an AWS batch function using serverless:

An error occurred: TestBatchLambdaFunction - The provided execution role does not have permissions to call CreateNetworkInterface on EC2 (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 66cd36bb-eaf5-420b-8880-359e52d985c1; Proxy: null).

Here is my serverless.yaml (clipped to be more succinct):

service: my-service
provider:
  name: aws
  runtime: nodejs10.x
  endpointType: REGIONAL
  region: ${file(./config/${opt:stage}.json):aws.region}
  memorySize: 3008
  timeout: 300
  logRetentionInDays: 7
  iamRoleStatements:
    - Effect: "Allow" # xray permissions (required)
      Action:
        - "xray:PutTraceSegments"
        - "xray:PutTelemetryRecords"
      Resource:
        - "*"      
    - Effect: Allow
      Action:
        - "ec2:CreateNetworkInterface"
        - "ec2:DescribeNetworkInterfaces"
        - "ec2:DetachNetworkInterface"
        - "ec2:DeleteNetworkInterface"
        - "forecast:*"
        - "s3:*"
        - 'lambda:InvokeFunction'
        - 'iam:PassRole'
      Resource: "*"
    - Effect: Allow
      Action:
        - "dynamodb:PutItem"
      Resource: "*"
  vpc: ${file(./config/${opt:stage}.json):aws.vpc}
  batch:
    Type: EC2
    BidPercentage: 100
    SecurityGroupIds: ${file(./config/${opt:stage}.json):aws.vpc.securityGroupIds}
    Subnets: ${file(./config/${opt:stage}.json):aws.vpc.subnetIds}
    InstanceTypes:
      - c5.large
    MinvCpus: 0
    MaxvCpus: 2

functions:
  testBatch:
    handler: index.testBatch
    batch:
      ContainerProperties:
        Memory: 3008
        Vcpus: 1

Any idea what I'm doing wrong, or am I hitting a bug in this plugin?

@rlyle
Copy link
Author

rlyle commented Nov 23, 2020

Update: I put the batch: onto an existing function in my serverless.yaml, and it deployed correctly this time.

@jeremyputeaux
Copy link

Just hit the same issue like @rlyle, had to comment the plugin in my serverless.yml configuration, deploy, uncomment it and deploy again.

@rlyle
Copy link
Author

rlyle commented Dec 3, 2020

Fixed this issue in my fork: https://github.com/rlyle/serverless-aws-batch

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

No branches or pull requests

2 participants