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

Bug: sam sync error when layer with ContentUri set to s3 object #6873

Closed
AlexMayleRdn opened this issue Mar 22, 2024 · 5 comments
Closed

Bug: sam sync error when layer with ContentUri set to s3 object #6873

AlexMayleRdn opened this issue Mar 22, 2024 · 5 comments
Labels
stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug

Comments

@AlexMayleRdn
Copy link

Description:

I'm aware that building layers whose ContentUri is specified as a s3 object is not supported, but I wouldn't expect having one to completely disable the ability to use sam sync.

Steps to reproduce:

Just write a template with a function and a layer whose ContentUri is an s3 object. Use sam deploy to deploy it.

Resources:
  AttachmentsFunction:
    # For specific SAM Template syntax
    # See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: esbuild
      BuildProperties:
        Target: node20
        EntryPoints:
          - index.ts
    Properties:
      FunctionName: attachments 
      Description: Attachment operations
      # A description of what changed in this version vs the others
      VersionDescription: !Ref ChangeLogNotes
      Handler: index.default
      CodeUri: ./src/Attachments/
      Timeout: 10
      # Tracing: !FindInMap [EnvMap, !Ref "EnvironmentName", Tracing]
      AutoPublishAlias: !Ref "Alias"
      VpcConfig:
        SecurityGroupIds: !FindInMap [EnvMap, !Ref "EnvironmentName", SecurityGroupIds]
        SubnetIds: !FindInMap [EnvMap, !Ref "EnvironmentName", SubnetIds]
      Policies:
        - arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
        - arn:aws:iam::aws:policy/AmazonS3FullAccess
      Runtime: nodejs20.x
      MemorySize: 128
      Environment:
        Variables:
          DB_HOSTNAME: !Ref "DatabaseHostname"
          DB_NAME: !Ref "DatabaseName"
          DB_PASSWORD: !Ref "DatabasePassword"
          DB_USERNAME: !Ref "DatabaseUsername"
          S3Bucket: !Ref "S3Bucket"
          S3Region: !Ref "S3Region"
  

  SomeFuncFunction:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: esbuild
      BuildProperties:
        Target: node20
        EntryPoints:
          - index.ts
    Properties:
      FunctionName: someFunc 
      Handler: index.default
      CodeUri: ./src
      Timeout: 30
      Layers:
        - !Ref ImageMagickLayer
      Runtime: nodejs20.x
      MemorySize: 512

  ImageMagickLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      CompatibleRuntimes:
      - nodejs20.x
      ContentUri:
        Bucket: awsserverlessrepo-changesets-1iiv3xa62ln3m
        Key: 158812218057/arn:aws:serverlessrepo:us-east-1:145266761615:applications-image-magick-lambda-layer-versions-1.0.0/cc8f7984-1453-4338-826b-536d2127e3f5
      Description: Static build of ImageMagick for AWS Linux 2
      LayerName: image-magick-al2
      RetentionPolicy: Retain

Then edit some code in the function and run sam sync --code --build-in-source --no-dependency-layer

Observed result:

2024-03-22 12:15:46,984 | No config file found in this directory.                                                              
2024-03-22 12:15:46,989 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                       
'/Users/alexmayle/repo/backend-api-attachments/samconfig.toml'                                                                 
2024-03-22 12:15:46,990 | Config file location: /Users/alexmayle/repo/backend-api-attachments/samconfig.toml                   
2024-03-22 12:15:46,991 | Config file '/Users/alexmayle/repo/backend-api-attachments/samconfig.toml' does not exist            
2024-03-22 12:15:47,016 | Using SAM Template at /Users/alexmayle/repo/backend-api-attachments/template.yaml                    
2024-03-22 12:15:47,072 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                       
'/Users/alexmayle/repo/backend-api-attachments/samconfig.toml'                                                                 
2024-03-22 12:15:47,097 | Telemetry endpoint configured to be                                                                  
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                                         
2024-03-22 12:15:47,098 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId':                                    
'18a9fd1f-10af-4500-a3b0-4a2f1be4387b', 'installationId': '773d95c3-02d0-4e7b-8d6b-75ad69de6775', 'sessionId':                 
'8e1a1f5a-f722-41d9-a009-35c06b04f57c', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion':    
'1.105.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': 'us-east-2', 'warningName': 'CodeDeployWarning',   
'warningCount': 0}}]}                                                                                                          
2024-03-22 12:15:47,417 | Telemetry response: 200                                                                              
2024-03-22 12:15:47,420 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId':                                    
'566e482f-b7f2-49e8-b696-da4de270ad27', 'installationId': '773d95c3-02d0-4e7b-8d6b-75ad69de6775', 'sessionId':                 
'8e1a1f5a-f722-41d9-a009-35c06b04f57c', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion':    
'1.105.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': 'us-east-2', 'warningName':                        
'CodeDeployConditionWarning', 'warningCount': 0}}]}                                                                            
2024-03-22 12:15:47,680 | Telemetry response: 200                                                                              
2024-03-22 12:15:47,683 | Using config file: samconfig.toml, config environment: default                                       
2024-03-22 12:15:47,685 | Expand command line arguments to:                                                                    
2024-03-22 12:15:47,686 | --template_file=/Users/alexmayle/repo/backend-api-attachments/template.yaml --code --watch           
--build_in_source --stack_name=backend-api-attachments --parameter_overrides={'DatabaseHostname': '--debug', 'EnvironmentName':
'staging', 'S3Bucket': 'rdn-super-staging-attachments', 'S3Region': 'us-east-2'} --skip_deploy_sync                            
--capabilities=('CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND')                                                              
2024-03-22 12:15:47,688 |                                                                                                      
The SAM CLI will use the AWS Lambda, Amazon API Gateway, and AWS StepFunctions APIs to upload your code without                
performing a CloudFormation deployment. This will cause drift in your CloudFormation stack.                                    
**The sync command should only be used against a development stack**.                                                          
                                                                                                                               
2024-03-22 12:15:48,000 | Using build directory as .aws-sam/build                                                              
2024-03-22 12:15:48,028 | Collected default values for parameters: {'DatabaseHostname': '', 'DatabasePassword': '',            
'DatabaseName': 'rdn_core', 'DatabaseUsername': 'backendapi', 'S3Bucket': 'rdn-staging-attachments', 'S3Region': 'us-west-2',  
'EnvironmentName': 'local', 'Alias': 'test', 'ChangeLogNotes': 'No Version description given.'}                                
2024-03-22 12:15:48,066 | There is no customer defined id or cdk path defined for resource AttachmentsFunction, so we will use 
the resource logical id as the resource id                                                                                     
2024-03-22 12:15:48,067 | There is no customer defined id or cdk path defined for resource CreateAttachmentThumbnailFunction,  
so we will use the resource logical id as the resource id                                                                      
2024-03-22 12:15:48,068 | There is no customer defined id or cdk path defined for resource ImageMagickLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,069 | There is no customer defined id or cdk path defined for resource GhostscriptLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,071 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,072 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,073 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,074 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,075 | 0 stacks found in the template                                                                       
2024-03-22 12:15:48,076 | Collected default values for parameters: {'DatabaseHostname': '', 'DatabasePassword': '',            
'DatabaseName': 'rdn_core', 'DatabaseUsername': 'backendapi', 'S3Bucket': 'rdn-staging-attachments', 'S3Region': 'us-west-2',  
'EnvironmentName': 'local', 'Alias': 'test', 'ChangeLogNotes': 'No Version description given.'}                                
2024-03-22 12:15:48,103 | There is no customer defined id or cdk path defined for resource AttachmentsFunction, so we will use 
the resource logical id as the resource id                                                                                     
2024-03-22 12:15:48,104 | There is no customer defined id or cdk path defined for resource CreateAttachmentThumbnailFunction,  
so we will use the resource logical id as the resource id                                                                      
2024-03-22 12:15:48,105 | There is no customer defined id or cdk path defined for resource ImageMagickLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,106 | There is no customer defined id or cdk path defined for resource GhostscriptLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,107 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,108 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,109 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,110 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,111 | 4 resources found in the stack                                                                       
2024-03-22 12:15:48,112 | Found Serverless function with name='AttachmentsFunction' and CodeUri='./src/Attachments/'           
2024-03-22 12:15:48,113 | --base-dir is not presented, adjusting uri ./src/Attachments/ relative to                            
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,114 | Resolved layer: ImageMagickLayer in current stack                                                    
2024-03-22 12:15:48,115 | The resource AWS::Serverless::LayerVersion 'ImageMagickLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,116 | Resolved layer: GhostscriptLayer in current stack                                                    
2024-03-22 12:15:48,117 | The resource AWS::Serverless::LayerVersion 'GhostscriptLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,117 | Found Serverless function with name='CreateAttachmentThumbnailFunction' and                          
CodeUri='./src/CreateThumbnail/'                                                                                               
2024-03-22 12:15:48,118 | --base-dir is not presented, adjusting uri ./src/CreateThumbnail/ relative to                        
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,120 | The resource AWS::Serverless::LayerVersion 'ImageMagickLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,121 | The resource AWS::Serverless::LayerVersion 'GhostscriptLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,127 | Entering sync context, previous state: SyncState(dependency_layer=False, resource_sync_states={},    
latest_infra_sync_time=None), current state: SyncState(dependency_layer=False, resource_sync_states={},                        
latest_infra_sync_time=None)                                                                                                   
2024-03-22 12:15:48,129 | You have enabled the --code flag, which limits sam sync updates to code changes only. To do a        
complete infrastructure and code sync, remove the --code flag.                                                                 
2024-03-22 12:15:48,153 | Collected default values for parameters: {'DatabaseHostname': '', 'DatabasePassword': '',            
'DatabaseName': 'rdn_core', 'DatabaseUsername': 'backendapi', 'S3Bucket': 'rdn-staging-attachments', 'S3Region': 'us-west-2',  
'EnvironmentName': 'local', 'Alias': 'test', 'ChangeLogNotes': 'No Version description given.'}                                
2024-03-22 12:15:48,154 | There is no customer defined id or cdk path defined for resource AttachmentsFunction, so we will use 
the resource logical id as the resource id                                                                                     
2024-03-22 12:15:48,155 | There is no customer defined id or cdk path defined for resource CreateAttachmentThumbnailFunction,  
so we will use the resource logical id as the resource id                                                                      
2024-03-22 12:15:48,156 | There is no customer defined id or cdk path defined for resource ImageMagickLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,157 | There is no customer defined id or cdk path defined for resource GhostscriptLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,158 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,159 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,160 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,161 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,162 | 0 stacks found in the template                                                                       
2024-03-22 12:15:48,163 | Loading physical ID mapping                                                                          
2024-03-22 12:15:48,181 | Fetching stack (backend-api-attachments) resources                                                   
2024-03-22 12:15:48,520 | Collected default values for parameters: {'DatabaseHostname': '', 'DatabasePassword': '',            
'DatabaseName': 'rdn_core', 'DatabaseUsername': 'backendapi', 'S3Bucket': 'rdn-staging-attachments', 'S3Region': 'us-west-2',  
'EnvironmentName': 'local', 'Alias': 'test', 'ChangeLogNotes': 'No Version description given.'}                                
2024-03-22 12:15:48,522 | There is no customer defined id or cdk path defined for resource AttachmentsFunction, so we will use 
the resource logical id as the resource id                                                                                     
2024-03-22 12:15:48,523 | There is no customer defined id or cdk path defined for resource CreateAttachmentThumbnailFunction,  
so we will use the resource logical id as the resource id                                                                      
2024-03-22 12:15:48,524 | There is no customer defined id or cdk path defined for resource ImageMagickLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,525 | There is no customer defined id or cdk path defined for resource GhostscriptLayer, so we will use the
resource logical id as the resource id                                                                                         
2024-03-22 12:15:48,527 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,528 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,529 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,530 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,532 | 0 stacks found in the template                                                                       
2024-03-22 12:15:48,581 | Collected default values for parameters: {'DatabaseHostname': '', 'DatabasePassword': '',            
'DatabaseName': 'rdn_core', 'DatabaseUsername': 'backendapi', 'S3Bucket': 'rdn-staging-attachments', 'S3Region': 'us-west-2',  
'EnvironmentName': 'local', 'Alias': 'test', 'ChangeLogNotes': 'No Version description given.'}                                
2024-03-22 12:15:48,611 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,612 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,614 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,615 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
GhostscriptLayer is GhostscriptLayer                                                                                           
2024-03-22 12:15:48,616 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,617 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,619 | Unable to resolve property SecurityGroupIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},
'SecurityGroupIds']}. Leaving as is.                                                                                           
2024-03-22 12:15:48,620 | Unable to resolve property SubnetIds: {'Fn::FindInMap': ['EnvMap', {'Ref': 'EnvironmentName'},       
'SubnetIds']}. Leaving as is.                                                                                                  
2024-03-22 12:15:48,621 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,622 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,623 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,624 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
GhostscriptLayer is GhostscriptLayer                                                                                           
2024-03-22 12:15:48,625 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,626 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,627 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,628 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,629 | 4 resources found in the stack                                                                       
2024-03-22 12:15:48,630 | Found Serverless function with name='AttachmentsFunction' and CodeUri='./src/Attachments/'           
2024-03-22 12:15:48,631 | --base-dir is not presented, adjusting uri ./src/Attachments/ relative to                            
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,632 | The resource AWS::Serverless::LayerVersion 'ImageMagickLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,633 | The resource AWS::Serverless::LayerVersion 'GhostscriptLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,634 | Found Serverless function with name='CreateAttachmentThumbnailFunction' and                          
CodeUri='./src/CreateThumbnail/'                                                                                               
2024-03-22 12:15:48,635 | --base-dir is not presented, adjusting uri ./src/CreateThumbnail/ relative to                        
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,637 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,638 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,639 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,640 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,641 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,642 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,643 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,644 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,645 | 4 resources found in the stack                                                                       
2024-03-22 12:15:48,646 | Found Serverless function with name='AttachmentsFunction' and CodeUri='./src/Attachments/'           
2024-03-22 12:15:48,646 | --base-dir is not presented, adjusting uri ./src/Attachments/ relative to                            
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,647 | The resource AWS::Serverless::LayerVersion 'ImageMagickLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,648 | The resource AWS::Serverless::LayerVersion 'GhostscriptLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,649 | Found Serverless function with name='CreateAttachmentThumbnailFunction' and                          
CodeUri='./src/CreateThumbnail/'                                                                                               
2024-03-22 12:15:48,650 | --base-dir is not presented, adjusting uri ./src/CreateThumbnail/ relative to                        
/Users/alexmayle/repo/backend-api-attachments/template.yaml                                                                    
2024-03-22 12:15:48,651 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,652 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,653 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,654 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,655 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,656 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,657 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,658 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,659 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,660 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
AttachmentsFunction is AttachmentsFunction                                                                                     
2024-03-22 12:15:48,660 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
CreateAttachmentThumbnailFunction is CreateAttachmentThumbnailFunction                                                         
2024-03-22 12:15:48,661 | Sam customer defined id is more priority than other IDs. Customer defined id for resource            
ImageMagickLayer is ImageMagickLayer                                                                                           
2024-03-22 12:15:48,662 | The resource AWS::Serverless::LayerVersion 'ImageMagickLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,663 | The resource AWS::Serverless::LayerVersion 'GhostscriptLayer' has specified S3 location for          
ContentUri. It will not be built and SAM CLI does not support invoking it locally.                                             
2024-03-22 12:15:48,666 | Telemetry endpoint configured to be                                                                  
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                                         
2024-03-22 12:15:48,666 | Unable to find Click Context for getting session_id.                                                 
2024-03-22 12:15:48,667 | Telemetry endpoint configured to be                                                                  
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                                         
2024-03-22 12:15:48,669 | Sending Telemetry: {'metrics': [{'events': {'requestId': '92604148-884a-48c3-8f26-9f893c740991',     
'installationId': '773d95c3-02d0-4e7b-8d6b-75ad69de6775', 'sessionId': '8e1a1f5a-f722-41d9-a009-35c06b04f57c',                 
'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion': '1.105.0', 'commandName': 'sam sync',      
'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id':          
'c280133e286743b69102ca191b10b207', 'time_stamp': '2024-03-22 16:15:46.990', 'exception_name': None}, {'event_name':           
'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'afd048ac35574fbfb477c3ce52bc5682', 'time_stamp': '2024-03-22   
16:15:47.073', 'exception_name': None}, {'event_name': 'SyncUsed', 'event_value': 'Start', 'thread_id':                        
'5182213d23b54f1e998930b26077e2fc', 'time_stamp': '2024-03-22 16:15:47.073', 'exception_name': None}, {'event_name':           
'UsedFeature', 'event_value': 'Accelerate', 'thread_id': '57e6ede96dc04273bcb50ac271765931', 'time_stamp': '2024-03-22         
16:15:48.001', 'exception_name': None}, {'event_name': 'SyncUsed', 'event_value': 'End', 'thread_id':                          
'5182213d23b54f1e998930b26077e2fc', 'time_stamp': '2024-03-22 16:15:48.665', 'exception_name': None}]}}}]}                     
2024-03-22 12:15:48,749 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'f513c0ae-1a39-417f-8676-2791a9a568c4', 
'installationId': '773d95c3-02d0-4e7b-8d6b-75ad69de6775', 'sessionId': '8e1a1f5a-f722-41d9-a009-35c06b04f57c',                 
'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion': '1.105.0', 'awsProfileProvided': True,     
'debugFlagProvided': True, 'region': 'us-east-2', 'commandName': 'sam sync', 'metricSpecificAttributes': {'projectType': 'CFN',
'gitOrigin': None, 'projectName': 'ac49cebd5261797e40b91047764a7271ebd00e0ad495d90bffe43c5a752e94e0', 'initialCommit': None},  
'duration': 1594, 'exitReason': 'ResourceNotFound', 'exitCode': 255}}]}                                                        
2024-03-22 12:15:48,944 | Telemetry response: 200                                                                              
2024-03-22 12:15:49,013 | Telemetry response: 200                                                                              

Error: 
Traceback:
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1688, in invoke
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "samcli/cli/cli_config_file.py", line 347, in wrapper
  File "click/decorators.py", line 92, in new_func
  File "click/core.py", line 783, in invoke
  File "samcli/lib/telemetry/metric.py", line 184, in wrapped
  File "samcli/lib/telemetry/metric.py", line 149, in wrapped
  File "samcli/lib/telemetry/event.py", line 376, in wrapped
  File "samcli/lib/telemetry/event.py", line 368, in wrapped
  File "samcli/lib/cli_validation/image_repository_validation.py", line 110, in wrapped
  File "samcli/lib/telemetry/metric.py", line 103, in wrapped
  File "samcli/lib/utils/version_checker.py", line 42, in wrapped
  File "samcli/cli/main.py", line 95, in wrapper
  File "samcli/commands/_utils/cdk_support_decorators.py", line 39, in wrapped
  File "samcli/commands/_utils/command_exception_handler.py", line 88, in wrapper_command_exception_handler
  File "samcli/commands/_utils/command_exception_handler.py", line 68, in wrapper_command_exception_handler
  File "samcli/commands/sync/command.py", line 225, in cli
  File "samcli/commands/sync/command.py", line 403, in do_cli
  File "samcli/commands/sync/command.py", line 564, in execute_watch
  File "samcli/lib/sync/watch_manager.py", line 214, in start
  File "samcli/lib/sync/watch_manager.py", line 242, in _start_sync
  File "samcli/lib/sync/watch_manager.py", line 140, in _add_code_triggers
  File "samcli/lib/utils/code_trigger_factory.py", line 119, in create_trigger
  File "samcli/lib/utils/code_trigger_factory.py", line 64, in _create_layer_trigger
  File "samcli/lib/utils/resource_trigger.py", line 305, in __init__

Expected result:

I expect the layer to not be built and just build the function. The function gets deployed and uses the layers. Note that a sam deploy command was already run so those layers exist. It seems that this command should succeed especially because the --code flag was used. By definition, these layers can't be updated from the working directory (since the content comes from s3) so sam sync will never be put in a position where it has to touch the layers. It can just ignore them and sync the function's code. It won't even have to update the function's layer versions because we are just syncing code here.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac OS 13.15.2
  2. sam --version: version 1.105.0
  3. AWS region: us-east-2
{
  "version": "1.105.0",
  "system": {
    "python": "3.8.13",
    "os": "macOS-13.5.2-x86_64-i386-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

@AlexMayleRdn AlexMayleRdn added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Mar 22, 2024
@mildaniel mildaniel added type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Mar 22, 2024
@mildaniel
Copy link
Contributor

Thanks @AlexMayleRdn. I agree, we should handle this case better and definitely shouldn't crash. I've marked this as a bug for prioritization.

@AlexMayleRdn
Copy link
Author

Any workaround you can see for the time being? I've been having to actually remove everything in my template other than my function I'm testing (it doesn't even use the layers) and running sam sync.

I've tried supplying the --resource-id of a function which does not use layers but alas.

@mildaniel
Copy link
Contributor

Are you able to use the sam local functionality in the meantime until we resolve this issue?

@mildaniel
Copy link
Contributor

For reference, we have done something similar for Lambda functions to skip trying to build a non-buildable artifact. We need to do the same thing for layers #5222

@hawflau hawflau added the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Jul 15, 2024
Copy link
Contributor

Patch is released in v1.121.0. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug
Projects
None yet
Development

No branches or pull requests

3 participants