bitrise-steplib/steps-amazon-s3-deploy

Specifying `region` results in incorrect URL

Closed this issue · 5 comments

Bitrise.yml on bitrise.io ( not cli ) spits out:

- amazon-s3-deploy@3.4.0:
        inputs:
        - aws_access_key: xxx
        - aws_secret_key: xxx
        - bucket_name: my-bucket-name
        - bucket_region: eu-central-1
        - path_in_bucket: bitrise_{app_slug}/{timestamp}_build_{build_slug}

As you can see from the logs the url is incorrect and is missing any reference to the Amazon servers:

load failed: ../deploy/app.ipa to 
s3://my-bucket-name/bitrise_{app_slug}/{timestamp}_build_{build_slug}/app.ipa

Some more details in the error log about regions from the AWS SDK:

A client error (InvalidRequest) occurred when calling the CreateMultipartUpload operation: 
You are attempting to operate on a bucket in a region that requires Signature Version 4.  
You can fix this issue by explicitly providing the correct region location using the --region argument, 
the AWS_DEFAULT_REGION environment variable, 
or the region variable in the AWS CLI configuration file.  
You can get the bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".

Ohh, I think I know what the issue is. You used the template value - path_in_bucket: bitrise_{app_slug}/{timestamp}_build_{build_slug} as the input.

We'll update the descriptions to make this clear, but the {..} placeholders are not handled by the step.

It's a quite old step, one of the first ones we wrote, and that time we thought it'll be a good idea to have a default value in the step if the input is empty. The bitrise_{app_slug}/{timestamp}_build_{build_slug} template means that if you leave the input empty the step will generate a format like that automatically - but you can't use the {..} placeholders directly.

You have to use Environment Variables just like for every other step input, e.g.: bitrise_$BITRISE_APP_SLUG/${BITRISE_BUILD_NUMER}_build_${BITRISE_BUILD_SLUG}.

Can you please try to set the value of path_in_bucket to this template/value? You can use the web editor too, to see all the available Environment Variables (click into the input text area and click on the "Insert Variable" button to see the full list).

Thank you @viktorbenei.
Result with your suggestions:

| (9) amazon-s3-deploy@3.4.0                                                   |
+------------------------------------------------------------------------------+
| id: amazon-s3-deploy                                                         |
| version: 3.4.0                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| time: 2016-03-09T06:36:30-08:00                                              |
+------------------------------------------------------------------------------+
|                                                                              |
INFO[06:36:31] (awscli) isn't installed, installing...      
INFO[06:36:47]  * [OK] awscli installed          
INFO[06:36:47]  * [OK] Step dependency (awscli) installed, available. 
"Options: {:ipa=>\"/Users/vagrant/deploy/MyApp.ipa\", :dsym=>\"/Users/vagrant/deploy/MyApp.dSYM.zip\", :app_slug=>\"b49e5d722b111111\", :build_slug=>\"fda49385911111111\", :access_key=>\"xxx\", :secret_key=>\"xxx\", :bucket_name=>\"my-bucket-name\", :bucket_region=>\"eu-central-1\", :path_in_bucket=>\"bitrise_b49e5d722b111111/fda49385911111111\", :acl=>\"public_read\"}"
# Amazon S3 Deploy
 (i) Base path in Bucket: bitrise_b49e5d722bfd3b8b/fda49385988eab35
-> Uploading IPA
upload failed: ../deploy/MyApp.ipa to s3://my-bucket-name/bitrise_b49e5d722b111111/fda49385911111111/MyApp.ipa
A client error (InvalidRequest) occurred when calling the CreateMultipartUpload operation: 
You are attempting to operate on a bucket in a region that requires Signature Version 4.  
You can fix this issue by explicitly providing the correct region location using the --region argument, 
the AWS_DEFAULT_REGION environment variable, or the region variable in the AWS CLI configuration file.  
You can get the bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".
 [!] Error: Failed to upload IPA
## Failed
Failed to upload IPA
Check the Logs for details.
status=failed
ERRO[06:36:56] Step (amazon-s3-deploy@3.4.0) failed, error: (exit status 1) ```

Hi @webdevotion ,
a new version (https://github.com/bitrise-io/steps-amazon-s3-deploy/releases/tag/3.5.0) will be available sonn. In this version step exports AWS_DEFAULT_REGION if input bucket_region is provided. This change should fix your issue.
We will notify you, as soon as step is released!

Thank you.

The new version is available now (if you'd not see it on bitrise.io just reload the page, the step database might be cached in your browser).

Sorry for the inconvenience and thanks for reporting the issue!