bitwalker / distillery-aws-example

An example application to go with the AWS guide in the Distillery documentation
Apache License 2.0
52 stars 73 forks source link

A few issues following the guide #5

Closed rlefevre closed 5 years ago

rlefevre commented 6 years ago

Hi,

Thank you very much for the Deploying to AWS guide and this repo, they have been extremely useful to me.

Here are a few issues I encountered following the guide:

1. GITHUB_TOKEN file

The bin/cfn script does GITHUB_TOKEN="$(cat "${SCRIPT_DIR}/../GITHUB_TOKEN" || "")", therefore without a GITHUB_TOKEN file, I got the following error:

cat: /tmp/distillery-aws-example/bin/../GITHUB_TOKEN: No such file or directory
./bin/cfn: line 9: : command not found

Adding the token in this file fixed the issue

2. S3 Buckets global identifiers

As S3 Buckets are global, it is not possible to create one if any other AWS account has already created it. When running bin/cfn create, I got the following error most likely because someone already deployed the distillery-aws-example-builds bucket and did not delete it:

An error occurred (AlreadyExistsException) when calling the CreateStack operation: Stack [distillery-aws-example] already exists
Stack  is being created, waiting for completion..

Waiter StackCreateComplete failed: Waiter encountered a terminal failure state

The S3 bucket name uses BucketName: !Sub "${ApplicationName}-builds", so changing the application name fixed the issue. Maybe the S3 bucket name or the application name could include a random part?

3. DeployApp failed on ValidateService

Application cannot start correctly because of the following error:

16:12:37.170 [error] Process #PID<0.1545.0> terminating
** (exit) "plug_cowboy dependency missing"

Adding {:plug_cowboy, "~> 1.0"} in mix.exs fixed the issue.

4. Minor documentation issue

Being new to distillery, I struggled to be able to run some release tasks to debug the failed application start. To be able to run ./bin/distillery_aws_example foreground, I had to connect as ec2-user by SSH to one ec2 instance, run sudo su to be root, go to /opt/app and run:

$ source /etc/network-environment
$ export DEFAULT_IPV4
$ set -o allexport
$ source etc/environment
$ set +o allexport
$  ./bin/distillery_aws_example foreground

Is there an easier way to run release tasks?

5. Minor issue with the TODO App

Once I successfully deployed the app, I noticed that it's not possible to complete a TODO in the TODO app (they can be checked but stay active). This is most likely not related to the AWS deployment at all so this is very minor. I didn't investigate the issue.

Thank you.

beno commented 5 years ago

I didn't get past step 1, what is it looking for? A file/script with then name GITHUB_TOKEN or the actual token? Either way it fails. I don't understand what this is trying to do.

rlefevre commented 5 years ago

@beno I created a file named GITHUB_TOKEN with the actual token in it.

beno commented 5 years ago

Thanks, did that too, but that seems so weird after setting it to an ENV var. Anyway, onward.

On 10 Dec 2018, at 16:03, rlefevre notifications@github.com wrote:

@beno https://github.com/beno I created a file named GITHUB_TOKEN with the actual token in it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitwalker/distillery-aws-example/issues/5#issuecomment-445846421, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC0oz4VvwG479e-RjNMCCGAiYJxvWovks5u3nezgaJpZM4YgrXk.

9mm commented 5 years ago

You can also change the cfn script to be this:

GITHUB_TOKEN="$(echo "$GITHUB_TOKEN")"
9mm commented 5 years ago

Yeah i wanted to follow this guide but this is super annoying nothing works. I get this when running cfn:

Waiter StackCreateComplete failed: Waiter encountered a terminal failure state
brucepom commented 5 years ago

Hey @9mm, the guide works well. There are things that can go wrong though. If you get a message like Waiter StackCreateComplete failed... You can always go into CloudFormation via the AWS console and get more info. You may find the error is a name conflict, you'll get an error like that if there is already a CF stack or AWS bucket with the same name as the resource you're trying to create. In particular, if your first attempt fails part way through it may have already created some of the stack resources. In that case be sure to delete the stack before trying again.

9mm commented 5 years ago

The problem was is that the name is global across all accounts if I remember right (it's been awhile). Considering I can't delete that, then it means the command in the guide will always fail.

brucepom commented 5 years ago

Yeah, I know what you mean, it was probably the S3 Bucket name, they need to be globally unique. I needed to change the bucket name as described by @rlefevre.