-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 top-level ELB Attachment resource #6879
Conversation
21de896
to
725f1c2
Compare
This LGTM 👍 with a few nitpicks:
|
Also I reckon enhancement to this resource will be requested soon - support for ASG/ELB attachment, but I think that can be part of another PR. |
@radeksimko thanks for the feedback! Yes, we were discussing making aws_elb_attachment resources additive rather than exclusive so that attachments could be defined in multiple places. Do we have the same dependency cycle problems with ASG attachments? the ELB and and LC are both defined in the ASG, so I'm not sure if there's a clear benefit there. |
I think that anyone wanting to do blue/green deployments in a way that each "colour" is managed in a separate Terraform context/directory may benefit from the additive approach. I think it can be still a list of instances to attach - i.e. It also makes sense in the light of Terraform being nice to existing infrastructure outside of Terraform - imagine a situation where user had existing ELB and wanted to use TF only for managing the relationship EC2/ELB. If you still believe that the exclusive approach is better, then I think the resource may be renamed to
What kind of dependency cycles do you mean? I'm not sure I follow. |
Ok, this just got a refactor and simplification. After discussing this more with @phinze, we're going to leave this as a single instance per attachment resource, rather than a list. The aligns with other resources we've broken out in this manner, and works better within in the limitations of the terraform internals. We can work on refactoring them all when we have a way to effectively manage this type of interdependent set of resources. @radeksimko the resource cycle I was referring to was what's described in issue #3999, but that isn't the only reason to add other things as separate resources either. |
return fmt.Errorf("Failure registering instances with ELB: %s", err) | ||
} | ||
|
||
d.SetId(resource.PrefixedUniqueId(fmt.Sprintf("%s-", elbName))) |
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.
Is there any reason why not just make this elbName
+ instance ID?
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.
An instance attached to the same ELB could change to a new aws_elb_attachment resource, creating a new resource with the same ID (I'm not sure if that's a problem in practice, but was being cautious).
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 see what do you mean, but both fields are ForceNew: true
anyway, so it's going to happen anyway.
My only concern about this is that it may make future resource importing slightly tricker. I haven't looked at the import functionality yet though, so maybe I'm wrong - in which case feel free to ignore this concern.
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.
The import won't work anyway since the lookup is not based on ID anyway, so it doesn't matter - see my other note about Importer
.
ok, I didn't have a strong opinion about this as much as I had about exclusive/additive approach, so I think we're pretty much on the same page here. 👌 I left you some other comments/questions in the code. |
Read: resourceAwsElbAttachmentRead, | ||
Delete: resourceAwsElbAttachmentDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, |
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 don't think this will actually work. The passthrough function is only supposed to work for ID-only imports as far as I know (and was able to read from the code I skimmed through).
It would be probably better to omit Importer
completely for now, until we figure out how to deal with import for such 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.
Yes, thanks for catching that, it was left from an earlier attempt.
I think importing would have to rely on the ELB importing them as a single list, which I think is probably fine. Either way we don't need Importer here, and can sort it out later if there are other options.
Looking great! A few final spacing / docs nits and this LGTM after those are addressed. 👍 |
Add an aws_elb_attachment resource so that the attment of instances to an ELB can be managed separately from an aws_elb and prevent dependency cycles.
|
LGTM |
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. |
Add an aws_elb_attachment resource so that the attment of instances to
an ELB can be managed separately from an aws_elb and prevent dependency
cycles.
fixes #3999