-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Support count in resource fields #7034
Comments
This would also be useful for aws_autoscaling_group |
This would also be useful for declaring |
This is an interesting take on block expansion! On first glance, I like the symmetry w/ resource expansion, but I'm not sure on auto-indexing splat behavior you reference. I'll do some thinking on this and swing back around. |
We just need a way to reference items in a list based on the count index. The below would work fine as well, I just like how clean the splat syntax looks.
Now that I look it up, I may have made up that splat syntax. I don't see a reference to it in the documentation. |
Just to add to this, it would also be useful for my use-case as well, multiple Instead of doing this:
We could do this:
|
Would this be a valid syntax option?
Also FYI, @dlanner: With the new list and map support in variables, you probably won't need to pass your configs into your module in CSV format anymore. In 0.7-rc2 you might be able to clean up your current setup to be something like |
I would also like to pass multiple settings to |
I'm trying to do the same thing as @jimsheldon. Is there a way to do this in |
Wanted to add another use case here: We have to define a
Having |
Maybe a new resource type could be created, aws_elastic_beanstalk_environment_setting for example, so the count would work as any other terraform resource, allowing us to write something like this: resource "aws_elastic_beanstalk_environment" "myEnv" {
...
}
resource "aws_elastic_beanstalk_environment_setting" "environment_variables" {
environment_id = "${aws_elastic_beanstalk_environment.myEnv.id}"
count = "${length(var.myvars)}"
...
} |
This would be super helpful in my current task of creating a reusable |
I would also like to see this implemented, because creating a reusable |
Just hit the same issue as others trying to create a reusable elastic_beanstalk module. Would be happy with either syntax enhancement or new resource type. |
Just another vote for the fleet launch specification use case. I reverted to using ERB templates being rendered by a makefile because we have almost 50 specifications per fleet. |
Another vote now that conditionals are allowed in Terraform 0.8
|
Wanted to add another vote for the spot fleet launch_specification use case. We end up with 20+ specifications per fleet and have many different fleets so it quickly gets out of control. This looks like a nice elegant solution. |
I would love to see this feature working \o / |
Good idea @cartolari. I broke that request out as a separate issue: #11314 Since it doesn't look like count in fields is on the roadmap, maybe we can get that fix implemented. |
I tried the following with Terraform v0.12.0-alpha1: provider "aws" {
region = "us-west-2"
}
variable "environment_vars" {
type = map(string)
default = {
FOO = "bar"
BAZ = "boop"
}
}
resource "aws_elastic_beanstalk_environment" "example" {
name = "test_environment"
application = "testing"
# Static Setting
setting {
namespace = "aws:autoscaling:asg"
name = "MinSize"
value = "1"
}
dynamic "setting" {
for_each = var.environment_vars
content {
namespace = "aws:elasticbeanstalk:application:environment"
name = setting.key
value = setting.value
}
}
} I don't have sufficient other Elastic Beanstalk infrastructure in my AWS account to apply this, but I was able to see it generating the expected result in So with all of that said, it seems that the new |
@apparentlymart will this new dynamic setting also support 0 resource blocks? So for example if I left variable empty, it won't create this blocks at all? |
@petrokashlikov yes I believe that should be the case. |
I couldn't get this to work. We build out two environments one with AAD integration and one without, so I was trying to dynamically create the azure_active_directory dependent on whether or not the params have been provided. This is the terraform defn
On terraform plan I get this:
But on terraform apply I get the error |
My bad I hadn't defined an empty list correctly for_each = "${var.aad_tenant_id != "" ? list("aad_reqd") : []}" Now works now :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I would like to be able to define repeated fields the same way I can define repeated resources. For instance, this could be used to set beanstalk environment vars based on a list passed in by a variable.
The text was updated successfully, but these errors were encountered: