Skip to content

Following example but getting error during deploy. #3

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

Closed
bvelasquez opened this issue May 20, 2019 · 3 comments
Closed

Following example but getting error during deploy. #3

bvelasquez opened this issue May 20, 2019 · 3 comments

Comments

@bvelasquez
Copy link

Hello, tried this to deploy react app. I'm getting the following error:

User: arn:aws:iam::398816301180:root is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:us-east-1:145266761615:layer:s3-deployment:5 (Service: AWSLambdaInternal; Status Code: 403; Error Code: AccessDeniedException; Request ID: 126fc2a9-7b38-11e9-a14d-51e70ccc31e9)

Using:

Resources:
  TargetBucket:
    Type: AWS::S3::Bucket
  SiteSource:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - arn:aws:lambda:us-east-1:145266761615:layer:s3-deployment:5
      CodeUri: web-site/
      AutoPublishAlias: live
      Runtime: python3.7
      Handler: deployer.resource_handler
      Timeout: 600
      Policies:
        - S3FullAccessPolicy:
            BucketName: !Ref TargetBucket
  DeploymentResource:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt SiteSource.Arn
      Version: !Ref "SiteSource.Version"
      TargetBucket: !Ref TargetBucket
      Acl: 'public-read'
      CacheControlMaxAge: 600
@gojko
Copy link
Contributor

gojko commented May 20, 2019

are you trying to deploy to us-east-1? if not, you will likely want to use the SAR version of this and then include it as a component in your app. try something like this:

  DeployToS3:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-east-1:375983427419:applications/deploy-to-s3
        SemanticVersion: 1.0.0
  SiteSource:
    Type: AWS::Serverless::Function
    Properties:
      Layers: 
        - !GetAtt DeployToS3.Outputs.Arn
      CodeUri: web-site/
      AutoPublishAlias: production
      Runtime: python3.7
      Handler: deployer.resource_handler
      Timeout: 600
      Policies:
        - S3FullAccessPolicy:
            BucketName: !Ref WebAssetsS3Bucket
  DeploymentResource:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt SiteSource.Arn
      Version: !Ref "SiteSource.Version"
      TargetBucket: !Ref WebAssetsS3Bucket
      Substitutions:
        FilePattern: "*.html"
        Values:
          API_URL: !Sub "https://${WebApi}.execute-api.${AWS::Region}.amazonaws.com/${AppStage}/"
          ALLOWED_TYPES: !Sub "${AllowedImageExtensions},${AllowedVideoExtensions}"
      Acl: 'public-read'
      CacheControlMaxAge: 600

@gojko gojko closed this as completed May 20, 2019
@kolomiets
Copy link

I'm deploying to us-east-1 and still getting the same error. I believe permissions are not properly configured for the layer.

I use the following command to verify if I have access to the public layer:

aws lambda get-layer-version --layer-name arn:aws:lambda:us-east-1:145266761615:layer:s3-deployment --version-number 5

In contrast, here is the layer I can access without issues (in the same us-east-1 region):

aws lambda get-layer-version --layer-name arn:aws:lambda:us-east-1:785355572843:layer:haskell-runtime --version-number 2

@gojko
Copy link
Contributor

gojko commented Jun 17, 2019

pull the layer from the serverless app repository, you will have the rights for that... for example

DeployToS3:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-east-1:375983427419:applications/deploy-to-s3
        SemanticVersion: 1.0.0
SiteSource:
    Type: AWS::Serverless::Function
    Properties:
      Layers: 
        - !GetAtt DeployToS3.Outputs.Arn
      CodeUri: web-site/
      AutoPublishAlias: production
      Runtime: python3.7
      Handler: deployer.resource_handler
      Timeout: 600
      Policies:
        - S3FullAccessPolicy:
            BucketName: !Ref WebAssetsS3Bucket
  DeploymentResource:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt SiteSource.Arn
      Version: !Ref "SiteSource.Version"
      TargetBucket: !Ref WebAssetsS3Bucket
      Acl: 'public-read'
      CacheControlMaxAge: 600

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

3 participants