-
Notifications
You must be signed in to change notification settings - Fork 9
Use automatic resource naming for S3 buckets #132
Conversation
395beaf
to
b9f027a
Compare
be4ce4a
to
b10f42f
Compare
fdcbbf5
to
98ef760
Compare
# get the resources | ||
resources = filter(fn, stack[0].list_resources()) | ||
else: | ||
resources = stack[0].list_resources() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be written a bit clearer. In pseudo code:
resources = stack.list_resources()
if resource_type:
resources = apply filter(resources)
The rule (which is never a hard and fast rule, cos they never are) to apply is that if you can easily limit if/else then it's easier to follow the code path through.
Apart from the minor fixes mentioned in comments the change looks good, but this is only part of the changes needed for #123 - we also need to adjust ELBs and RDS instances similarly. I'm happy to merge this change before then but we need to change the PR and commit message to not close the issue as it's not complete yet. |
5af4c54
to
ed56810
Compare
Fixup commit for review. |
ed56810
to
87f7787
Compare
Currently we use hard coded names for resources like S3. This change will allow us to use dynamic names auto-generated by aws and exposed as an output. (Closes #123) - S3 bucket names are optional in config, default to dynamic ones - Add a method and fab_file function to allow getting a filtered list of resources - Update tests to look for new BucketName output and policy changes - Add test to check config with s3 key but no subkeys loads ok - PEP8 fixes
87f7787
to
8b05569
Compare
Have squashed and rebased |
"StaticBucketName", | ||
Description="S3 bucket name", | ||
Value=Ref("StaticBucket") | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok time to refactor here - we shouldn't be creating things outside of the s3
function that relate to things inside it.
Options I can think of:
-
lists-of-lists from
s3()
-
we could pass the Troposphere template object in to the class and let the s3 call
add_resource
oradd_output
as it needs. -
We can return a list of objects and detect where to add them. Something like:
objs = self.s3() self.add_to_template(template, objs) # … def add_to_template(self, template, objects) for object in objs: if isinstance(obj, troposphere.Output): template.add_output(obj) elif isinstance(obj, troposphere.Parameter): template.add_parameter(obj)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used the 'returning the output list' option with ELB but I'm moving more towards the 'passing the template' option
1f488da
to
63922fb
Compare
Fixups added,
|
63922fb
to
47db5d8
Compare
47db5d8
to
738ffde
Compare
Updated testing to cover s3 outputs values as well |
Use automatic resource naming for S3 buckets
Currently we use hard coded names for resources like S3. This change
will allow us to use dynamic names auto-generated by aws and exposed
as an output. (Closes #123)
list of resources