yarbsemaj / sveltekit-adapter-lambda

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework or CDK.
https://www.npmjs.com/package/@yarbsemaj/adapter-lambda
MIT License
77 stars 16 forks source link

Deploy Error: CREATE_FAILED: StaticAssets (AWS::S3::Bucket) #11

Closed coderpradp closed 2 years ago

coderpradp commented 2 years ago

SvelteKit: 1.0.0-next.348 @yarbsemaj/adapter-lambda: 0.9.1

Copied serverless.yml as is from this repo to root directory. Build was successful however I'm getting Error: CREATE_FAILED: StaticAssets (AWS::S3::Bucket) on deploy. Tried removing everything (serverless remove) and deploying again but same error.

Here are some logs if it helps:

λ serverless deploy --verbose
Running "serverless" from node_modules

Deploying sveltekit-app to stage dev (us-east-1)

Packaging
Excluding development dependencies for function "svelte"
Excluding development dependencies for function "cfLambda"
Updated Lambda assume role policy to allow Lambda@Edge to assume the role
Added "origin-request" Lambda@Edge association for version "CfLambdaLambdaVersion9d8whyATJFrfutff6mjOifOMyJ8rhrJ2DIVrLuh1i8" to distribution "WebsiteDistribution"
Retrieving CloudFormation stack
Creating CloudFormation stack
Creating new change set
Waiting for new change set to be created
Change Set did not reach desired state, retrying
Executing created change set
  CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev
  CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
  CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_COMPLETE - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
  CREATE_COMPLETE - AWS::CloudFormation::Stack - sveltekit-app-dev
Uploading
Uploading CloudFormation file to S3                                                                                                   
Uploading State file to S3                                                                                                            
Uploading service svelte.zip file to S3 (102.52 kB)                                                                                   
Uploading service cfLambda.zip file to S3 (102.52 kB)                                                                                 
Updating CloudFormation stack                                                                                                         
Creating new change set                                                                                                               
Waiting for new change set to be created                                                                                              
Change Set did not reach desired state, retrying                                                                                      
Executing created change set                                                                                                          
  UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                                                 
  CREATE_IN_PROGRESS - AWS::S3::Bucket - StaticAssets                                                                                 
  CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution                                                                        
  CREATE_IN_PROGRESS - AWS::Logs::LogGroup - SvelteLogGroup                                                                           
  CREATE_IN_PROGRESS - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                         
  CREATE_FAILED - AWS::S3::Bucket - StaticAssets                                                                                      
  CREATE_FAILED - AWS::Logs::LogGroup - SvelteLogGroup                                                                                
  CREATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution                                                                             
  CREATE_FAILED - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                              
  UPDATE_ROLLBACK_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                                        
  UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - sveltekit-app-dev                                       
  DELETE_COMPLETE - AWS::S3::Bucket - StaticAssets                                                                                    
  DELETE_COMPLETE - AWS::Logs::LogGroup - SvelteLogGroup                                                                              
  DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution                                                                        
  DELETE_COMPLETE - AWS::Logs::LogGroup - CfLambdaLogGroup                                                                            
  DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution                                                                           
  UPDATE_ROLLBACK_COMPLETE - AWS::CloudFormation::Stack - sveltekit-app-dev                                                           

× Stack sveltekit-app-dev failed to deploy (116s)                                                                                     
Environment: win32, node 16.15.1, framework 3.19.0 (local) 3.19.0v (global), plugin 6.2.2, SDK 4.3.2                                  
Credentials: Local, "default" profile                                                                                                 
Docs:        docs.serverless.com                                                                                                      
Support:     forum.serverless.com                                                                                                     
Bugs:        github.com/serverless/serverless/issues                                                                                  

Error:                                                                                                                                
CREATE_FAILED: StaticAssets (AWS::S3::Bucket)                                                                                         
dev-sveltekit-app-static-assets already exists                                                                                        

View the full error: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A306836384016%3Astack%2Fsveltekit-app-dev%2F2922b930-f3e3-11ec-8f77-0ecff273accf

1 deprecation found: run 'serverless doctor' for more details

image

coderpradp commented 2 years ago

I forgot to modify the bucket name in serverless.yml. Bucket name needs to be unique.

richardvaldivieso commented 4 months ago

I have the same problem, but I do not want to change the name of the bucket every single time that I deploy, how can I fix this problem?

yarbsemaj commented 4 months ago

Hi @richardvaldivieso, thank you for your interest in my project!

you shouldn't need to change the service name with every deploy (unless you want to deploy multiple sites), the issue described above is caused by 2 factors,

Once the static assets bucket has been created then serverless should not try and recreate it and instead should just deploy your assets to the existing bucket.

Thanks James