简体   繁体   中英

Terraform | Change a resource created by a public module

Let's say that I'm creating an AWS ECS cluster with the help of a public or internal module that I cannot directly change. That module is creating, besides the ECS, let's say a couple of SGs, some alb, maybe an ACM cert, etc. It's all good BUT, for the sake of this problem, I don't like the SGs configs and would like to change them but the developer did not provide a var for that.

Is there a way for me to reference a particular SG(or any other resource) created by that module and then overwrite/change/replace its config?

Or do I have to create a PR in the repo of that module to add the necessary vars/changes?

In Terraform it's the responsibility of a module author to decide the scope of that module and tailor its input variables and output values to meet that scope. There is no way to add additional customization capabilities to a module from the perspective of a caller, because that would then cause your customizations to be effectively a compatibility constraint on future changes to the module which the module author has no awareness of, and therefore cannot predict.

If a particular module doesn't meet your needs then your options are, unfortunately, much the same as they are for third-party libraries in most language ecosystems:

  • Send a feature request to the maintainers (and possibly also a pull request to implement that feature) and see if the maintainers are willing to accept your new requirement into their scope.
  • Assuming that the module uses a suitable open source license, use it as the basis for your own module which meets a similar need as the original module but that is extended to meet your specific requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM