-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for List of Tag Maps #18
Conversation
Hah, yes, this is now entirely possible with locals. Question then becomes, what provider does it belong under? https://www.terraform.io/docs/registry/modules/publish.html#requirements We might want to create a new module under that provider, since https://github.com/terraform-providers/terraform-provider-terraform |
We were recently faced with this conundrum here: cloudposse/terraform-aws-key-pair#12 (see discussion for some context) |
I see. So for it to be published publicly it needs to be named by the provider. The locals is part of core terraform. I imagine that you could name it core or terraform for the middle name? And retire the null provider repo? Since it requires extra downloading and initializing, unlike locals? |
Fwiw, here's a repo if you want to rebase your change ontop of it: https://github.com/cloudposse/terraform-terraform-label |
Thank you. I have something even better to show you with my next commit. |
Updated to allow for tagging of Autoscaling groups. It was really damn hard guys, really hard to getthat stupid thing expanding as a dynamic list.
@osterman I've created a new technique for use in this module, and I have put the null provider back in to handle it. |
@aknysh Is this being reviewed? |
…tor section. fixed copy paste error in table.
main.tf
Outdated
}" | ||
|
||
tags_asg_propagate_true = ["${null_resource.tags_asg_propagate_true.*.triggers}"] | ||
tags_asg_propagate_false = ["${null_resource.tags_asg_propagate_false.*.triggers}"] |
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.
@Jamie-BitFlight
thanks again!
please remove everything related to other technologies and services from this module.
it's the lowest-level generic module which all other modules use.
it should not mention anything like EC2 or ASG.
(this could be in the advanced examples though)
README.md
Outdated
@@ -148,6 +229,8 @@ resource "aws_instance" "eg_prod_bastion_xyz" { | |||
| namespace | Normalized namespace | | |||
| stage | Normalized stage | | |||
| tags | Merge input tags with our tags. Note: `Name` has a special meaning in AWS and we need to disamgiuate it by using the computed `id` | | |||
| tags_asg_propagate_true | a list of maps that contain the ASG format tags with propagation set to true | | |||
| tags_asg_propagate_false | a list of maps that contain the ASG format tags with propagation set to false | |
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.
@Jamie-BitFlight
please remove everything related to other technologies and services from this module.
it's the lowest-level generic module which all other modules use.
it should not mention anything like EC2 or ASG in the inputs.
thanks
main.tf
Outdated
} | ||
} | ||
|
||
resource "null_resource" "tags_asg_propagate_false" { |
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.
here too :)
outputs.tf
Outdated
|
||
description = "Normalized Tag map" | ||
} | ||
|
||
output "tags_asg_propagate_true" { |
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.
and here
I think Just wonder though if we should rename both outputs for consistency:
@aknysh thoughts? |
If you change |
examples/autoscalinggroup/main.tf
Outdated
###################### | ||
# Autoscaling group # | ||
###################### | ||
resource "aws_autoscaling_group" "this" { |
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.
We typically use default
in place of this
. Using this
is also a good convention, but let's stick with default
since that's what we have else where.
@aknysh LGTM; one small nitpick on |
examples/autoscalinggroup/main.tf
Outdated
source = "../../" | ||
namespace = "awesomeproject" | ||
stage = "production" | ||
name = "clusterpluck" |
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.
does not sound good.
please use our standard conventions:
namespace = "cp"
stage = "prod"
name = "app"
README.md
Outdated
@@ -121,6 +121,93 @@ resource "aws_instance" "eg_prod_bastion_xyz" { | |||
vpc_security_group_ids = ["${aws_security_group.eg_prod_bastion_xyz.id}"] | |||
} | |||
``` | |||
### Advanced Example 2 | |||
|
|||
Here is a more complex example with an autoscaling group that has a different tagging schema than other resources and requres its tags to be in this format, which this module can generate: |
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.
typo in requres
README.md
Outdated
source = "../../" | ||
namespace = "awesomeproject" | ||
stage = "production" | ||
name = "clusterpluck" |
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.
does not sound good.
please use our standard conventions:
namespace = "cp"
stage = "prod"
name = "app"
README.md
Outdated
] | ||
``` | ||
|
||
Autoscaling group using proagating tagging below (full example: examples/autoscalinggroup/main.tf) |
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.
typo in proagating
README.md
Outdated
####################### | ||
# Launch template # | ||
####################### | ||
resource "aws_launch_template" "this" { |
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.
change this
to default
as it's used in all CloudPosse modules
README.md
Outdated
###################### | ||
# Autoscaling group # | ||
###################### | ||
resource "aws_autoscaling_group" "this" { |
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.
change this
to default
as it's used in all CloudPosse modules
outputs.tf
Outdated
|
||
output "tags_as_list_of_maps" { | ||
value = ["${local.tags_as_list_of_maps}"] | ||
description = "Additional tags as a list of maps. Which can be used in several 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.
Additional tags as a list of maps, which can be used in several AWS resources
variables.tf
Outdated
@@ -32,3 +32,9 @@ variable "tags" { | |||
default = {} | |||
description = "Additional tags (e.g. `map('BusinessUnit`,`XYZ`)" |
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.
please also update the quotes
Additional tags (e.g. map('BusinessUnit','XYZ')
)
* upstream/master: Another little terraform typo (cloudposse#20)
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.
@Jamie-BitFlight
thanks
we are close, just a few comments
* 'master' of github.com:Jamie-BitFlight/terraform-null-label:
Those have been addressed @aknysh |
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.
+1
@Jamie-BitFlight |
Thanks for working with me on this. |
what
why