aws-samples / lambda-refarch-mobilebackend

Serverless Reference Architecture for creating a Mobile Backend
Apache License 2.0
587 stars 113 forks source link

Unable to get the refarch working in EU location #11

Open modond opened 8 years ago

modond commented 8 years ago

I have made a (global) S3 bucket and copied the mobile-backend.template and the config-helper.template. Then I made another S3 bucket to hold the lambda-functions and copied the folder search/index.js, folder stream-handler/index.js, folder upload-note/index.js as well as files package.sh and upload.sh.

I created a cloud search domain, an api gateway and a cognito identity pool (federated) in my EU region. I have checked and found all variables parameterized, except the constants.swift file which should not come into play before I start up the iOs demo?..

I started the cloud formation from the S3 bucket/mobile-backend.template.

These are the events in Test01 (name of the stack)

2016-06-20 Status Type Logical ID Status reason 15:21:14 UTC+0200 DELETE_COMPLETE AWS::DynamoDB::Table PhotoNotesTable 15:20:43 UTC+0200 DELETE_COMPLETE AWS::IAM::Role DynamoStreamHandlerRole 15:20:43 UTC+0200 DELETE_IN_PROGRESS AWS::DynamoDB::Table PhotoNotesTable 15:20:42 UTC+0200 DELETE_COMPLETE AWS::IAM::Role SearchApiRole
15:20:42 UTC+0200 DELETE_COMPLETE AWS::IAM::Role NotesApiRole
15:20:41 UTC+0200 DELETE_IN_PROGRESS AWS::IAM::Role DynamoStreamHandlerRole 15:20:41 UTC+0200 DELETE_COMPLETE AWS::IAM::Role MobileClientRole
15:20:41 UTC+0200 DELETE_IN_PROGRESS AWS::IAM::Role SearchApiRole
15:20:40 UTC+0200 DELETE_IN_PROGRESS AWS::IAM::Role NotesApiRole
15:20:40 UTC+0200 DELETE_IN_PROGRESS AWS::IAM::Role MobileClientRole
15:20:40 UTC+0200 DELETE_IN_PROGRESS AWS::CloudFront::Distribution CloudFrontDistribution
15:20:40 UTC+0200 DELETE_COMPLETE AWS::Lambda::Function DynamoStreamHandlerFunction 15:20:40 UTC+0200 DELETE_COMPLETE AWS::Lambda::Function SearchApiFunction
15:20:34 UTC+0200 ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack Test01 The following resource(s) failed to create: [MobileClientRole, SearchApiFunction, NotesApiRole, CloudFrontDistribution, DynamoStreamHandlerFunction]. . Rollback requested by user. 15:20:34 UTC+0200 CREATEFAILED AWS::Lambda::Function DynamoStreamHandlerFunction 1 validation error detected: Value 'lambda-mobilebackend-cloudformation/lambda-functions' at 'code.s3Bucket' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[0-9A-Za-z.-](?<!.)$ 15:20:33 UTC+0200 CREATE_FAILED AWS::IAM::Role MobileClientRole Resource creation cancelled 15:20:33 UTC+0200 CREATE_FAILED AWS::CloudFront::Distribution CloudFrontDistribution Resource creation cancelled 15:20:33 UTC+0200 CREATE_FAILED AWS::IAM::Role NotesApiRole Resource creation cancelled 15:20:33 UTC+0200 CREATE_IN_PROGRESS AWS::Lambda::Function DynamoStreamHandlerFunction 15:20:33 UTC+0200 CREATEFAILED AWS::Lambda::Function SearchApiFunction 1 validation error detected: Value 'lambda-mobilebackend-cloudformation/lambda-functions' at 'code.s3Bucket' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[0-9A-Za-z.-](?<!.)$ 15:20:32 UTC+0200 CREATE_IN_PROGRESS AWS::Lambda::Function SearchApiFunction
15:20:29 UTC+0200 CREATE_COMPLETE AWS::IAM::Role DynamoStreamHandlerRole Physical ID:Test01-DynamoStreamHandlerRole-U6K870VS12NN 15:20:29 UTC+0200 CREATE_COMPLETE AWS::IAM::Role SearchApiRole
15:20:18 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role MobileClientRole Resource creation Initiated 15:20:10 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role NotesApiRole
15:19:53 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role SearchApiRole Resource creation Initiated 15:19:53 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role DynamoStreamHandlerRole Resource creation Initiated 15:19:48 UTC+0200 CREATE_COMPLETE AWS::DynamoDB::Table PhotoNotesTable 15:19:43 UTC+0200 CREATE_IN_PROGRESS AWS::CloudFront::Distribution CloudFrontDistribution Resource creation Initiated 15:19:43 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role MobileClientRole
15:19:42 UTC+0200 CREATE_IN_PROGRESS AWS::CloudFront::Distribution CloudFrontDistribution
15:19:39 UTC+0200 CREATE_COMPLETE AWS::S3::Bucket MobileUploadsBucket 15:19:18 UTC+0200 CREATE_IN_PROGRESS AWS::S3::Bucket MobileUploadsBucket Resource creation Initiated 15:19:18 UTC+0200 CREATE_IN_PROGRESS AWS::DynamoDB::Table PhotoNotesTable Resource creation Initiated 15:19:17 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role SearchApiRole
15:19:17 UTC+0200 CREATE_IN_PROGRESS AWS::IAM::Role DynamoStreamHandlerRole 15:19:17 UTC+0200 CREATE_IN_PROGRESS AWS::S3::Bucket MobileUploadsBucket 15:19:17 UTC+0200 CREATE_IN_PROGRESS AWS::DynamoDB::Table PhotoNotesTable 15:19:14 UTC+0200 CREATE_IN_PROGRESS AWS::CloudFormation::Stack Test01 User Initiated


I launched the stack in Virginia successfully with the cloud formation template. The github explanation tells met to just copy the template and lambda functions in an S3 bucket and refer from my region.. to start the stack

What am I doing wrong.. thank you

mikedeck commented 8 years ago

Sorry for the difficulties here. The instructions aren't very clear. I'll work to update that.

You need to have a single bucket and prefix with all of the templates and packages in one place.

The easiest way to do this is going to be to use this AWS CLI command: aws s3 sync --source-region us-east-1 --region YOUR_BUCKET_REGION --exclude LICENSE --exclude README.md s3://awslambda-reference-architectures/mobile-backend/ s3://YOUR_BUCKET_NAME/mobile-backend/

Unfortunately, this will copy a few extra files you don't need, but that shouldn't effect your ability to launch the template.

Then to launch the template use the URL https://s3.[REGION].amazonaws.com/[YOUR_BUCKET_NAME]/mobile-backend/mobile-backend.template, and specify your bucket for CodeBucket and "mobile-backend" for CodeKeyPrefix.

modond commented 8 years ago

Hi there Mike,

Thank you for the explanation. I have done as described, which neatly puts the files in an S3 bucket (which is accessible global..) So I address it with a URL https://s3.[NO REGION SPECIFIED].amazonaws.com/[MY_BUCKET_NAME]/mobile-backend/mobile-backend.template.

If I specify the region (eu-west-1) then the cf stack creator gives me an error. If I don't specify, it accepts the URL, however.. I think that this is still not right, here is my output (again I am having trouble with automatically bootstrapping necessary IAM roles...):


10:16:42 UTC+0200 ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack Lambda-mobilebackend-eu The following resource(s) failed to create: [MobileClientRole, SearchApiFunction, NotesApiRole, CloudFrontDistribution]. . Rollback requested by user. 10:16:41 UTC+0200 CREATE_FAILED AWS::IAM::Role MobileClientRole Resource creation cancelled 10:16:41 UTC+0200 CREATE_FAILED AWS::IAM::Role NotesApiRole Resource creation cancelled 10:16:41 UTC+0200 CREATE_FAILED AWS::CloudFront::Distribution CloudFrontDistribution Resource creation cancelled 10:16:40 UTC+0200 CREATE_FAILED AWS::Lambda::Function SearchApiFunction Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.


jmsaizc commented 7 years ago

I try deploy cf in eu-west-1 region with bucket synced and region specified in url template but still not working:

12:38:18 UTC+0200 | CREATE_FAILED | AWS::Lambda::Function | SearchApiFunction | Resource creation cancelled   | 12:38:17 UTC+0200 | CREATE_FAILED | AWS::Lambda::Function | DynamoStreamHandlerFunction | Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket is in this region: us-east-1. Please use this region to retry the request   | Client Request Token:Console-CreateStack-08afc108-a500-4df4-b0c2-0ace5006fd0a   | 12:38:08 UTC+0200 | CREATE_IN_PROGRESS | AWS::Lambda::Function | NotesApiFunction |     | 12:38:07 UTC+0200 | CREATE_IN_PROGRESS | AWS::Lambda::Function | SearchApiFunction |     | 12:38:06 UTC+0200 | CREATE_IN_PROGRESS | AWS::Lambda::Function | DynamoStreamHandlerFunction