-
Notifications
You must be signed in to change notification settings - Fork 98
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
Ability to associated contract with ESG without going into the resource for creating the ESG. #1157
Comments
Hi @JockeW-DvL , thanks for raising this issue. I have added it to the todo items. |
Classes that should be configured:
|
Hi @JockeW-DvL, The aci_epg_to_contract resource would actually work for esg also. You should be able to do the following:
Please let me know if you face any issues. |
It works the first apply run, but if i do a second apply run without changing any config all the contracts will be removed from the ESGs. if i do a third apply run the contracts will then be reapplyd again. The output from Terraform on the second run is:
Just one example of the contracts beeing removed. |
Hi @JockeW-DvL, just to get a better understanding, could you provide your configuration also? I assume you do not define any contract relationships in aci_endpoint_security_group.terraform_esg configuration. |
Of course Akini, Here are the config i am using: for building the ESGs:
And the indata for the above resource:
and the configuration for doing the mapping between ESG and contract:
And the indata for the above resourse:
|
Hi @JockeW-DvL, I had a quick look today to see if I could find a quick solution to specify it in the ESG resource. Is there a reason that you are specifying the objects outside the resource, because I think this might solve your problems until we make changes. See example below and let me know if that could help you change your TF configuration logic a bit.
|
Hello Akini, If you look at my resourse definition i'm using for_each for the whole resource, and the reason behind this is that we have around 150-200 different ESGs that need to be created. The reason i want to have the mapping outside of the resource is 2-fold: |
Hi @JockeW-DvL, Ok thanks for the additional information, this is currently indeed not possible. The resource assumes that you define all the relationships to the ESG whenever you manage an ESG. As a workaround you could define the ESG in another terraform configuration. Thus have a configuration that has datasource for ESG and then the relations defined, this way the changes made in relationship are not impacting the a resource that is defined in the same configuration. The problem would still occur that when there is a apply of configuration where the ESG is defined, but would be limited. Another option would be to adjust the data structure of you input. Both solutions are not ideal I would say. We are working on a change for this behaviour, but this would also mean changes to the behaviour of the ESG resource where we need to detect None is provided in the relationship attribute. This is only possible starting the new terraform-plugin-framework, thus will depend on the migration of our resources to this new way. |
I can try and have the resources for creating the ESGs and the association of the Contract and ESG in separate workspaces and report back if this works as intended. |
Hi @JockeW-DvL, I was thinking a bit more about your problem and think the best way would probably be to define a local module. This way you bypass the restriction of the nested for_each. Also this way you would not have the situation you were describing whenever there is a apply needed in the code where ESG is specified. I have tested and created some example code that I can share with you over email but probably best if we set up a call for this to walk through it since it is multiple files. Could you send me an email so we can set something up? |
Hello Akini,I came to the same conclusion earlier today.I’ve gotten half of the terraform files created and will test this in the coming days (when my schedule allows)Regards Joacim W On 6 March 2024 at 17:49:13, Akini Ross ***@***.***) wrote:
Hi @JockeW-DvL,
I was thinking a bit more about your problem and think the best way would probably be to define a local module. This way you bypass the restriction of the nested for_each. Also this way you would not have the situation you were describing whenever there is a apply needed in the code where ESG is specified.
I have tested and created some example code that I can share with you over email but probably best if we set up a call for this to walk through it since it is multiple files. Could you send me an email so we can set something up?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#1157 (comment)",
"url": "#1157 (comment)",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
|
Hi @JockeW-DvL, I was running some additional checks and noticed that the behaviour is also not matching the behaviour as we have in the EPG resource. I have labeled it as a bug now and we will be looking into a fix. Please follow the issue for PR updates and leverage the module workaround for now in case you need an immediate fix. Apologies for the inconvenience. |
Hi @JockeW-DvL, so looking at the code and running several tests drew me to the following conclusion. We need to migrate the resource into plugin framework in order for this to be fixed. The difference between EPG and ESG modules is that the ESG module exposes a list of maps, where the EPG module exposes a list of strings. In SDKv2 (framework to develop resources) the list of strings is written to state as Null when not provided, however for the list of maps it is written to a empty list. This difference in attribute handling makes it impossible for us to properly detect that a attribute is not provided and thus should not be touched. So for now the only way around this is the module workaround mentioned above. |
body{font-family:Helvetica,Arial;font-size:13px}Hello Akini,Thanks for the update. I would like to setup a webex-meeting so that you can show me the example code you’ve used.RegardsJoacim W On 11 March 2024 at 09:29:17, Akini Ross ***@***.***) wrote:
Hi @JockeW-DvL, so looking at the code and running several tests drew me to the following conclusion. We need to migrate the resource into plugin framework in order for this to be fixed. The difference between EPG and ESG modules is that the ESG module exposes a list of maps, where the EPG module exposes a list of strings. In SDKv2 (framework to develop resources) the list of strings is written to state as Null when not provided, however for the list of maps it is written to a empty list. This difference in attribute handling makes it impossible for us to properly detect that a attribute is not provided and thus should not be touched. So for now the only way around this is the module workaround mentioned above.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I have some time now if you are available, can you send me an email directly so we can schedule something? |
body{font-family:Helvetica,Arial;font-size:13px}Hello Akini,I’m working with another customer all day today, but tommorow have time between 10 and 12 tomorrow.RegardsJoacim W On 14 March 2024 at 09:08:41, Akini Ross ***@***.***) wrote:
I have some time now if you are available, can you send me an email directly so we can schedule something?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Community Note
Description
I'm in need of a resource for associating contracts and ESG's the same way we can do with EPG's, i.e. the same as aci_epg_to_contract.
The reason behind this request is that i need a way of associating contracts to ESG's without beeing forced to rebuild/change the ESG for every run of terraform apply.
New or Affected Resource(s) + ACI Class(es):
APIC version and APIC Platform
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: