aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
71 stars 14 forks source link

The Synthetics Canary update-canary command doesn't pull updated code from S3 #489

Closed endre-synnes closed 6 months ago

endre-synnes commented 1 year ago

Describe the bug

When running the aws synthetics update-canary command, It seems that the Canary is updated, since the timestamp changes, but the code/script is not updated.

The code is stored in an S3 bucket, and I can confirm that the S3 bucket does contain my updated script.

Expected Behavior

  1. Running: aws synthetics update-canary --name <CANARY_NAME> --code '{"S3Bucket": "<S3_BUCKET_NAME>", "S3Key":"<S3_KEY>", "Handler": "<HANDLER_FILE_AND_FUNCTION>", "S3Version": "<S3_OBJECT_VERSION>"}'

  2. Returning: success message.

  3. Timestamp for last updated is changed.

  4. Canary script successfully updated.

Current Behavior

  1. Running: aws synthetics update-canary --name <CANARY_NAME> --code '{"S3Bucket": "<S3_BUCKET_NAME>", "S3Key":"<S3_KEY>", "Handler": "<HANDLER_FILE_AND_FUNCTION>", "S3Version": "<S3_OBJECT_VERSION>"}'

  2. Returning: success message

  3. Timestamp for last updated is changed.

  4. Script not updated.

Reproduction Steps

  1. Create canary and use S3 as data source for the script (I have used the terraform resource to initially create the Canary.).
  2. Verify that the Canary is created and runs successfully.
  3. Upload new version of the canary script to the s3 bucket.
  4. Run the aws synthetics update-canary CLI command to make Canary pull new script: aws synthetics update-canary --name <CANARY_NAME> --code '{"S3Bucket": "<S3_BUCKET_NAME>", "S3Key":"<S3_KEY>", "Handler": "<HANDLER_FILE_AND_FUNCTION>", "S3Version": "<S3_OBJECT_VERSION>"}'

Possible Solution

I'm not sure how to fix this issue, but It would be great to have some form sort of an error message if the update command is actually failing.

Additional Information/Context

There is no error returned when I execute the command, and if I run it in debug mode, Its not logging any issues.

CLI version used

2.2.38

Environment details (OS name and version, etc.)

Mac OS version 13.2.1

endre-synnes commented 1 year ago

Update:

It seems that the aws synthetics update-canary command does work. The issue was a typo in the parameters I provided to the update-canary command.

Still, in my opinion the update command should have returned an error message. The only reason I was able to figure out that the cause of this issue was a typo, was that ran the aws synthetics get-canary command. In the response object the Status field said that there was an Key error when trying to retrieve the code from S3.

I would have expected that the same error had been visible in the Synthetics Canary overview in the AWS Console as well.

tim-finnigan commented 1 year ago

Hi @endre-synnes thanks for reaching out. I'm glad to hear you were able to get that command working. If your parameter has a typo then you should get a generic Unknown options: ... error, for example:

aws synthetics update-canary --name my-canary --codee ...

Results in: Unknown options: --codee, ...

What you're describing may be a more subtle issue with the UpdateCanary API, in which case we could forward this feedback to the Synthetics team as they are the owners of that API. I think we would first just need more information on the runtime behavior. If you want to share your logs (with any sensitive info redacted) by adding --debug to your command then that could give more insight into the issue.

endre-synnes commented 1 year ago

Hi @tim-finnigan,

Thank you for looking into this issue. I think the issue is a bit mote subtle. The typo was in the value of the --code parameter and not the key itself. To be a bit more specific, I used the wrong file name for the S3Key property. This caused the key error when Synthetics (or AWS Lambda) tried to retrieve the object from S3. I would expect this error to be displayed in the response from the aws synthetics update-canary command.

As far as I can see, this error is not displayed in the debug logs either, but I'l provide it here so you can forward it to the Synthetics team if that's of any interest 😊

I have redacted all of the sensitive info and replaced it with dummy strings in all caps.

## Command:

aws synthetics update-canary --name CANARY_NAME --code '{"S3Bucket": "MY_S3_BUCKET", "S3Key":"MISSING_FILE.zip", "Handler": "MY_PYTHON_FILE.HANDLER_FUNCTION"}' --debug

## LOGS:

2023-02-27 08:59:02,069 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.2.38 Python/3.8.8 Darwin/22.3.0 exe/x86_64
2023-02-27 08:59:02,069 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['synthetics', 'update-canary', '--name', 'CANARY_NAME', '--code', '{"S3Bucket": "MY_S3_BUCKET", "S3Key":"MISSING_FILE.zip", "Handler": "MY_PYTHON_FILE.HANDLER_FUNCTION"}', '--debug']
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_s3 at 0x7f832881c430>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_ddb at 0x7f8300306a60>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.configure.configure.ConfigureCommand'>>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7f83183151f0>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7f831831e1f0>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function alias_opsworks_cm at 0x7f82f855fe50>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_history_commands at 0x7f8300351820>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.devcommands.CLIDevCommand'>>
2023-02-27 08:59:02,107 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_waiters at 0x7f82f855f0d0>
2023-02-27 08:59:02,108 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/data/cli.json
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_types at 0x7f83287dd310>
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function no_sign_request at 0x7f83287dde50>
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_verify_ssl at 0x7f83287dddc0>
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_read_timeout at 0x7f83287ddf70>
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_connect_timeout at 0x7f83287ddee0>
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <built-in method update of dict object at 0x7f8300417f00>
2023-02-27 08:59:02,111 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.2.38 Python/3.8.8 Darwin/22.3.0 exe/x86_64 prompt/off
2023-02-27 08:59:02,111 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['synthetics', 'update-canary', '--name', 'CANARY_NAME', '--code', '{"S3Bucket": "MY_S3_BUCKET", "S3Key":"MISSING_FILE.zip", "Handler": "MY_PYTHON_FILE.HANDLER_FUNCTION"}', '--debug']
2023-02-27 08:59:02,111 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x7f832881ca60>
2023-02-27 08:59:02,112 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7f83287439d0>
2023-02-27 08:59:02,112 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x7f83003db4c0>
2023-02-27 08:59:02,112 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function no_pager_handler at 0x7f832873dd30>
2023-02-27 08:59:02,112 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7f83287a3310>
2023-02-27 08:59:02,121 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/
2023-02-27 08:59:02,130 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7f8300351700>
2023-02-27 08:59:02,130 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x7f83002fd940>
2023-02-27 08:59:02,168 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/synthetics/2017-10-11/service-2.json
2023-02-27 08:59:02,170 - MainThread - botocore.hooks - DEBUG - Event building-command-table.synthetics: calling handler <function add_waiters at 0x7f82f855f0d0>
2023-02-27 08:59:02,203 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('name', <awscli.arguments.CLIArgument object at 0x7f8308305970>), ('code', <awscli.arguments.CLIArgument object at 0x7f8308305940>), ('execution-role-arn', <awscli.arguments.CLIArgument object at 0x7f8308305b50>), ('runtime-version', <awscli.arguments.CLIArgument object at 0x7f8308305b80>), ('schedule', <awscli.arguments.CLIArgument object at 0x7f8308305be0>), ('run-config', <awscli.arguments.CLIArgument object at 0x7f8308305c10>), ('success-retention-period-in-days', <awscli.arguments.CLIArgument object at 0x7f8308305bb0>), ('failure-retention-period-in-days', <awscli.arguments.CLIArgument object at 0x7f8308305c40>), ('vpc-config', <awscli.arguments.CLIArgument object at 0x7f8308305c70>), ('visual-reference', <awscli.arguments.CLIArgument object at 0x7f8308305ca0>)])
2023-02-27 08:59:02,203 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.synthetics.update-canary: calling handler <function add_streaming_output_arg at 0x7f82f8554040>
2023-02-27 08:59:02,203 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.synthetics.update-canary: calling handler <function add_cli_input_json at 0x7f83287a3b80>
2023-02-27 08:59:02,204 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.synthetics.update-canary: calling handler <function add_cli_input_yaml at 0x7f83287a3e50>
2023-02-27 08:59:02,204 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.synthetics.update-canary: calling handler <function unify_paging_params at 0x7f83003150d0>
2023-02-27 08:59:02,237 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/synthetics/2017-10-11/paginators-1.json
2023-02-27 08:59:02,237 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.synthetics.update-canary: calling handler <function add_generate_skeleton at 0x7f83287d48b0>
2023-02-27 08:59:02,238 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.synthetics.update-canary: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x7f8308305df0>>
2023-02-27 08:59:02,238 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.synthetics.update-canary: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x7f8308305e20>>
2023-02-27 08:59:02,238 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.synthetics.update-canary: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f8308305e50>>
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.name: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.synthetics.update-canary: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f8328769e20>
2023-02-27 08:59:02,239 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'CANARY_NAME' for parameter "name": 'CANARY_NAME'
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.code: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.synthetics.update-canary: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f8328769e20>
2023-02-27 08:59:02,239 - MainThread - awscli.argprocess - DEBUG - Param code looks like JSON, not considered for param shorthand.
2023-02-27 08:59:02,239 - MainThread - awscli.arguments - DEBUG - Unpacked value of '{"S3Bucket": "MY_S3_BUCKET", "S3Key":"MISSING_FILE.zip", "Handler": "MY_PYTHON_FILE.HANDLER_FUNCTION"}' for parameter "code": OrderedDict([('S3Bucket', 'MY_S3_BUCKET'), ('S3Key', 'MISSING_FILE.zip'), ('Handler', 'MY_PYTHON_FILE.HANDLER_FUNCTION')])
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.execution-role-arn: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.runtime-version: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,239 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.schedule: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.run-config: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.success-retention-period-in-days: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.failure-retention-period-in-days: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.vpc-config: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.visual-reference: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.cli-input-yaml: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.synthetics.update-canary.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f830045dc70>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event calling-command.synthetics.update-canary: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x7f8308305df0>>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event calling-command.synthetics.update-canary: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x7f8308305e20>>
2023-02-27 08:59:02,240 - MainThread - botocore.hooks - DEBUG - Event calling-command.synthetics.update-canary: calling handler <bound method GenerateCliSkeletonArgument.generate_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f8308305e50>>
2023-02-27 08:59:02,240 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2023-02-27 08:59:02,240 - MainThread - botocore.credentials - INFO - Found credentials in environment variables.
2023-02-27 08:59:02,242 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/endpoints.json
2023-02-27 08:59:02,251 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f83181c93a0>
2023-02-27 08:59:02,251 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.synthetics: calling handler <function add_generate_presigned_url at 0x7f8318177940>
2023-02-27 08:59:02,252 - MainThread - botocore.regions - DEBUG - Creating a regex based endpoint for synthetics, eu-west-1
2023-02-27 08:59:02,254 - MainThread - botocore.endpoint - DEBUG - Setting synthetics timeout as (60, 60)
2023-02-27 08:59:02,255 - MainThread - botocore.hooks - DEBUG - Event provide-client-params.synthetics.UpdateCanary: calling handler <function base64_decode_input_blobs at 0x7f83003dbc10>
2023-02-27 08:59:02,255 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.synthetics.UpdateCanary: calling handler <function generate_idempotent_uuid at 0x7f83181e83a0>
2023-02-27 08:59:02,255 - MainThread - botocore.hooks - DEBUG - Event before-call.synthetics.UpdateCanary: calling handler <function inject_api_version_header_if_needed at 0x7f83181eac10>
2023-02-27 08:59:02,255 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=UpdateCanary) with params: {'url_path': '/canary/CANARY_NAME', 'query_string': {}, 'method': 'PATCH', 'headers': {'User-Agent': 'aws-cli/2.2.38 Python/3.8.8 Darwin/22.3.0 exe/x86_64 prompt/off command/synthetics.update-canary'}, 'body': b'{"Code": {"S3Bucket": "MY_S3_BUCKET", "S3Key": "MISSING_FILE.zip", "Handler": "MY_PYTHON_FILE.HANDLER_FUNCTION"}}', 'url': 'https://synthetics.eu-west-1.amazonaws.com/canary/CANARY_NAME', 'context': {'client_region': 'eu-west-1', 'client_config': <botocore.config.Config object at 0x7f8318348130>, 'has_streaming_input': False, 'auth_type': None}}
2023-02-27 08:59:02,255 - MainThread - botocore.hooks - DEBUG - Event request-created.synthetics.UpdateCanary: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f8318348250>>
2023-02-27 08:59:02,256 - MainThread - botocore.hooks - DEBUG - Event choose-signer.synthetics.UpdateCanary: calling handler <function set_operation_specific_signer at 0x7f83181e8280>
2023-02-27 08:59:02,256 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth.
2023-02-27 08:59:02,256 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
PATCH
/canary/CANARY_NAME

host:synthetics.eu-west-1.amazonaws.com
x-amz-date:20230227T075902Z
x-amz-security-token: TOKEN

host;x-amz-date;x-amz-security-token
SENSITIVE
2023-02-27 08:59:02,257 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20230227T075902Z
20230227/eu-west-1/synthetics/aws4_request
SENSITIVE
2023-02-27 08:59:02,258 - MainThread - botocore.auth - DEBUG - Signature:
SENSITIVE
2023-02-27 08:59:02,258 - MainThread - botocore.endpoint - DEBUG - Sending http request: <AWSPreparedRequest stream_output=False, method=PATCH, url=https://synthetics.eu-west-1.amazonaws.com/canary/CANARY_NAME, headers={'User-Agent': b'aws-cli/2.2.38 Python/3.8.8 Darwin/22.3.0 exe/x86_64 prompt/off command/synthetics.update-canary', 'X-Amz-Date': b'20230227T075902Z', 'X-Amz-Security-Token': b'TOKEN', 'Authorization': b'AUTHORIZATION', 'Content-Length': '132'}>
2023-02-27 08:59:02,258 - MainThread - botocore.httpsession - DEBUG - Certificate path: /usr/local/aws-cli/botocore/cacert.pem
2023-02-27 08:59:02,258 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): synthetics.eu-west-1.amazonaws.com:443
2023-02-27 08:59:02,747 - MainThread - urllib3.connectionpool - DEBUG - https://synthetics.eu-west-1.amazonaws.com:443 "PATCH /canary/CANARY_NAME HTTP/1.1" 200 2
2023-02-27 08:59:02,748 - MainThread - botocore.parsers - DEBUG - Response headers: {'Date': 'Mon, 27 Feb 2023 07:59:02 GMT', 'Content-Type': 'application/json', 'Content-Length': '2', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'REQUEST_ID', 'x-amz-apigw-id': 'API_GW_ID', 'X-Amzn-Trace-Id': 'Root=TRACE_ID'}
2023-02-27 08:59:02,748 - MainThread - botocore.parsers - DEBUG - Response body:
b'{}'
2023-02-27 08:59:02,749 - MainThread - botocore.hooks - DEBUG - Event needs-retry.synthetics.UpdateCanary: calling handler <bound method RetryHandler.needs_retry of <botocore.retries.standard.RetryHandler object at 0x7f8300472400>>
2023-02-27 08:59:02,749 - MainThread - botocore.retries.standard - DEBUG - Not retrying request.
2023-02-27 08:59:02,749 - MainThread - botocore.hooks - DEBUG - Event after-call.synthetics.UpdateCanary: calling handler <bound method RetryQuotaChecker.release_retry_quota of <botocore.retries.standard.RetryQuotaChecker object at 0x7f8318348f70>>
2023-02-27 08:59:02,749 - MainThread - awscli.formatter - DEBUG - RequestId: REQUEST_ID
tim-finnigan commented 1 year ago

Thanks for following up and sharing those logs. I could also reproduce the behavior you described. I'm going to transfer this issue to our cross-SDK repository and reach out to the Synthetics team for further review.

tim-finnigan commented 1 year ago

P123914801

endre-synnes commented 1 year ago

Thanks for following up and sharing those logs. I could also reproduce the behavior you described. I'm going to transfer this issue to our cross-SDK repository and reach out to the Synthetics team for further review.

Thank you @tim-finnigan!

vitalii-shemetov commented 1 year ago

Hello @tim-finnigan Are there any updates on that? I'm having the same issue

vitalii-shemetov commented 1 year ago

@endre-synnes @tim-finnigan I managed to solve the issue by RTFM of AWS CLI command. In my case, there were 2 issues:

  1. Invalid folders structure in canary.zip
  2. "S3Bucket" value should be specified without "S3://"

Here is an example of my command line which works for me: I run it from Windows Cmd:

update-canary --region us-east-1 --name my_canary --debug --no-verify-ssl --code="{\"S3Bucket\":\"some-autotests-bucket\",\"S3Key\":\"canary.zip\",\"Handler\":\"index.handler\"}"

I hope it will be useful

saugion commented 1 year ago

I have a similar issue: i'm trying to update a canary with a web-identity role-based, i receive a 200 as response but the environment variables are not updated. Same operation with my aws user, it works fine, and the response is basically the same.

The oidc role's policy is

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:GetBucketLocation",
                "s3:ListAllMyBuckets",
                "cloudwatch:PutMetricData",
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "synthetics:*"
            ],
            "Resource": "*"
        }
    ]
}
tim-finnigan commented 6 months ago

Thanks all for your patience here. I discussed this issue with a member of the service team, who noted that this behavior is expected because the UpdateCanary API is functioning asynchronously. Therefore it is not designed to validate the existence of an S3 key in a customer account. Once the command finishes running, the canary will go in ERROR state. A get-canary call on it will show the reason for failure, which should look something like this:

"Status": {
            "State": "ERROR",
            "StateReason": "Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist. (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: <>; Proxy: null)",
            "StateReasonCode": "UPDATE_FAILED"
        }

I suggested that the documentation be updated to better clarify this behavior. I encourage anyone else who stumbles on this to click the Provide feedback button at the bottom of the API documentation page. Any updates to the API documentation will be reflected in the CLI/SDK docs. Thanks again for reporting this issue.

github-actions[bot] commented 6 months ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.