Description:
When running sam sync --watch with a nested stack containing
an ECR-based Lambda function, the sync fails with a datetime
comparison error in SAM's internal code.
SAM CLI Version:
1.149.0
OS:
Linux 6.8.0-87-generic (Ubuntu)
Steps to Reproduce:
-
Create a SAM template with a nested stack
(AWS::CloudFormation::Stack) that references a local template:
RecruiticsMLStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ./THEMLTemplate.yaml
Parameters:
EnvType: !Ref EnvType
-
The nested template contains a Lambda function using an ECR
image:
generateRecruiticsFlags:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.a
mazonaws.com/my-repo:latest"
-
Run sam sync --watch:
sam sync --watch --stack-name my-stack --region eu-west-1
--parameter-overrides EnvType=dev --template THETemplate.yaml
Expected Behavior:
Infra sync completes successfully.
Actual Behavior:
Build succeeds, but infra sync fails with:
Failed to sync infra. Code sync is paused until template/stack
is fixed.
Traceback (most recent call last):
File "samcli/lib/sync/watch_manager.py", line 269, in
_execute_infra_sync
File "samcli/lib/sync/watch_manager.py", line 199, in
_execute_infra_context
File "samcli/lib/sync/infra_sync_executor.py", line 176, in
execute_infra_sync
TypeError: can't subtract offset-naive and offset-aware
datetimes
Additional Context:
- The nested stack deploys successfully via sam deploy
(non-watch mode)
- SAM shows this warning before the error: The resource
AWS::Serverless::Function 'generateRecruiticsFlags' has
specified ECR registry image for ImageUri. It will not be
built and SAM CLI does not support invoking it locally.
- The error appears to be in SAM's datetime handling when
comparing stack update times, not in the template itself
Workaround:
Using sam deploy instead of sam sync --watch works correctly (this is a terrible work-flow of course with poor feedback loop experience compared to sam sync --watch)
Description:
When running sam sync --watch with a nested stack containing
an ECR-based Lambda function, the sync fails with a datetime
comparison error in SAM's internal code.
SAM CLI Version:
1.149.0
OS:
Linux 6.8.0-87-generic (Ubuntu)
Steps to Reproduce:
Create a SAM template with a nested stack
(AWS::CloudFormation::Stack) that references a local template:
RecruiticsMLStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ./THEMLTemplate.yaml
Parameters:
EnvType: !Ref EnvType
The nested template contains a Lambda function using an ECR
image:
generateRecruiticsFlags:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.a
mazonaws.com/my-repo:latest"
Run sam sync --watch:
sam sync --watch --stack-name my-stack --region eu-west-1
--parameter-overrides EnvType=dev --template THETemplate.yaml
Expected Behavior:
Infra sync completes successfully.
Actual Behavior:
Build succeeds, but infra sync fails with:
Failed to sync infra. Code sync is paused until template/stack
is fixed.
Traceback (most recent call last):
File "samcli/lib/sync/watch_manager.py", line 269, in
_execute_infra_sync
File "samcli/lib/sync/watch_manager.py", line 199, in
_execute_infra_context
File "samcli/lib/sync/infra_sync_executor.py", line 176, in
execute_infra_sync
TypeError: can't subtract offset-naive and offset-aware
datetimes
Additional Context:
(non-watch mode)
AWS::Serverless::Function 'generateRecruiticsFlags' has
specified ECR registry image for ImageUri. It will not be
built and SAM CLI does not support invoking it locally.
comparing stack update times, not in the template itself
Workaround:
Using sam deploy instead of sam sync --watch works correctly (this is a terrible work-flow of course with poor feedback loop experience compared to sam sync --watch)