An error occurred: bucket already exists in stack

Hi,

I’m new here, and I’m a little bit lost

This question has already been asked(Error: Bucket already exists when redeployed) , but the solution in the answer doesn’t seem to work for me.

# serverless.yml

service: my-app

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-west-2
  vpc:
    securityGroupIds:
      - sg-xxxxxxxxx 
    subnetIds:
      - subnet-xxxxxx
      - subnet-xxxxxx
      - subnet-xxxxxx

functions:
  app:
    handler: index.handler
    events:
      - http: ANY /
      - http: 'ANY {proxy+}'
  resize:
    handler: resize.handler
    events:
      - s3: photos

resources:
  Resources:
    S3BucketPhotos:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-bucket
    ResizeLambdaPermissionPhotosS3:
      Type: "AWS::Lambda::Permission"
      Properties:
        FunctionName:
          "Fn::GetAtt":
            - ResizeLambdaFunction
            - Arn
        Principal: "s3.amazonaws.com"
        Action: "lambda:InvokeFunction"
        SourceAccount:
          Ref: AWS::AccountId
        SourceArn: "arn:aws:s3:::my-bucket"

plugins:
  - serverless-offline

When I remove the Resources section, it deploys but the bucket is not created and the triggers for that bucket are not set.

I created the bucket manually and removed the resources section and it deployed, but something was still not right. I added a iamRoleStatement and now the it is adding the trigger to the lambda function, but it doesn’t trigger and when I test the lambda function it stalls when downloading the original file. There is definitively something wrong with this iamRoleStatement

iamRoleStatements:
    - Effect: Allow
      Action:
           - "s3:*"
           - SES:Publish
      Resource: "arn:aws:s3:::my-bucket/*"

Ok, so the problem was I had to add a VPC endpoint to connect S3 to my VPC