Skip to content

Added module key_pairs#1

Open
nascimento wants to merge 3 commits intoGlennChia:masterfrom
nascimento:master
Open

Added module key_pairs#1
nascimento wants to merge 3 commits intoGlennChia:masterfrom
nascimento:master

Conversation

@nascimento
Copy link

Proposal to create key pairs automatically.

@GlennChia
Copy link
Owner

Hi Vitor, good suggestion to create keys automatically.

These are some possible things we may want to consider

  1. Some of the other resources like GitLab and Gitaly currently reference the key via a variable which supplies the name. If we create the keys automatically, these resources may have to depend on the key creation before proceeding to avoid errors in resource creation
  2. Could we add a condition to give users an option for whether they want to use their existing keys (what was done previously) or create the keys via the module (the change proposed)? Perhaps a condition to create the module based on a variable would be good
  3. There could be an issue where users want to use the same key for all instances (This is not good security practice but is convenient for a small hobby project). In this case if we create the keys in a module this way, if they share a similar name it will produce an error.

Do let me know your thoughts and it's cool to meet someone who is interesting in automating the GitLab installation on AWS too!

@nascimento
Copy link
Author

Hi Glenn ..

  1. If you to keep key_pairs module on top of main.tf file It will not happen. Anyway depends_on could be a alternative solution, right?
  2. yes, an option to choise between create automatically or not is a good idea.
  3. I think it`s not good practice maybe do not need an option for this. So said that and a small project want to use a same key for all resources they could create your own call to module passing hardcoded key name. But I think the code or module dont need to provide this option.

What do you think?

@GlennChia
Copy link
Owner

Hi Vitor, these are my thoughts

  1. The dependencies can be solved if the other modules reference the key pair attributes from the key pair module like module.key_pair.<key_pair_attribute>. This way it will create the key pairs first. However, if we have an option to create the key_pairs or bring your own key_pair then this dependency could throw an error if users bring their own key_pair and then there is still the dependency module.key_pair.<key_pair_attribute> in the other modules. One work around is to use the same condition that created the key_pair to either refer to module.key_pair.<key_pair_attribute> or var.key_pair_name

  2. Yes, we should definitely include that condition

  3. Yup, agreed it is not best practice and if we want to enforce the use of different keys, it is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants