Skip to content

Commit

Permalink
Move S3 templates into sub-dirs in S3 (#478)
Browse files Browse the repository at this point in the history
* Move S3 templates into sub-dirs in S3

Fixes #347

This adds another layer to the s3 bucket space to try and keep things a
bit cleaner.  If you had a namespace of `mynamespace`, a bucket of
`mybucket`, and a stack called `vpc`, the old method would have resulted
in an s3 key of:

`s3://mybucket/vpc-$version.json`

It would now result in:

`s3://mybucket/mynamespace-vpc/vpc-$version.json`

Not 100% sure that's the best namespace use, but it seems specific
enough and should be helpful.

I'm pretty sure this will result in slower runs the first time after
updating to this version of stacker, only because it'll have to upload
all it's templates again, but it shouldn't result in any CloudFormation
updates.  I'll verify this.

* Prepend s3 path with `/stack_templates/`
  • Loading branch information
phobologic committed Sep 24, 2017
1 parent baf084b commit 6c31a11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion stacker/actions/base.py
Expand Up @@ -24,7 +24,10 @@ def stack_template_key_name(blueprint):
Returns:
string: Key name resulting from blueprint.
"""
return "%s-%s.json" % (blueprint.name, blueprint.version)
name = blueprint.name
return "stack_templates/%s/%s-%s.json" % (blueprint.context.get_fqn(name),
name,
blueprint.version)


def stack_template_url(bucket_name, blueprint, endpoint):
Expand Down
3 changes: 2 additions & 1 deletion stacker/tests/actions/test_base.py
Expand Up @@ -129,9 +129,10 @@ def test_stack_template_url(self):
)
self.assertEqual(
action.stack_template_url(blueprint),
"https://%s/%s/%s-%s.json" % (
"https://%s/%s/stack_templates/%s/%s-%s.json" % (
endpoint,
"stacker-mynamespace",
"mynamespace-myblueprint",
"myblueprint",
MOCK_VERSION

Expand Down

0 comments on commit 6c31a11

Please sign in to comment.