realestate-com-au / stackup

a simple CLI and Ruby API for AWS CloudFormation
MIT License
97 stars 34 forks source link

Support templates pulled from S3 #37

Closed andrewoh531 closed 7 years ago

andrewoh531 commented 7 years ago

Can templates existing in either S3 or Github be referenced? Can't see anything in the documentation and tried referencing a template in S3 but got a ERROR: no such file response.

mdub commented 7 years ago

Stackup's Ruby API does supports a :template_url option, which can be used to reference templates stored in S3.

But I'm afraid the stackup CLI and Rake tasks don't support external templates right now. It wouldn't be hard to add; I'll consider this a feature-request.

mdub commented 7 years ago

@andrewoh531: I've just released stackup v1.1.0, which allows templates (and other things) to be specified as HTTP URLs, rather than local files. e.g.

stackup mystack up -t https://s3-ap-southeast-2.amazonaws.com/some-bucket/template.json

It even works for diff, as well:

stackup mystack diff -t https://s3-ap-southeast-2.amazonaws.com/some-bucket/template.json

When the template URL refers to an object in S3, stackup will just pass the reference to CloudFormation. In other cases, it will actually download the template itself, and pass it along; this means you could even pull a template from GitHub, or any other website.

Please give it a try, and let me know if it works for you.

andrewoh531 commented 7 years ago

@mdub thanks for the quick turn around. Tried testing it but got a ERROR: 403 Forbidden: "https://s3-ap-southeast-2.amazonaws.com/andrewoh-cloudformation-templates/ecs-service.yml".

I'm able to retrieve the object running an aws cp command though.

mdub commented 7 years ago

Try making the object public, @andrewoh531.

I'm pretty sure this is a CloudFormation API constraint - the URL must be an HTTPS one, and is downloaded (by CF) over HTTPS, not the S3 protocol.

I think you'd hit the same limitation if you were using the AWS CLI.

andrewoh531 commented 7 years ago

Ah right. AWS CLI doesn't have that limitation. I'm able to run aws cloudformation create-stack or update-stack with the --template-url parameter that references a non-public template in S3. It seems to be using the credentials used to execute the cfn command.

If it's too much work that's ok. I'm using a workaround which pulls the template down first and references it locally.

mdub commented 7 years ago

Oh, you're quite right. I stuffed it up; fix coming soon.

mdub commented 7 years ago

Give v1.1.1 a try. I've been able to make it work with a non-public template in S3.

mdub commented 7 years ago

I'm calling this done. The feature is there now; raise another issue if it turns out to be buggy.

andrewoh531 commented 7 years ago

Thanks! Tested it out and it worked. Thanks for the quick turnaround!