Skip to content
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

feat: add support for the user_data variable #916

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open

Conversation

Aashiq-J
Copy link
Member

@Aashiq-J Aashiq-J commented Nov 13, 2024

Description

Issue: #863

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

Aashiq-J and others added 30 commits December 19, 2023 08:12
@Aashiq-J
Copy link
Member Author

/run pipeline

@Aashiq-J Aashiq-J mentioned this pull request Nov 13, 2024
3 tasks
@imprateeksh
Copy link
Member

/run pipeline

variables.tf Outdated
@@ -289,6 +289,20 @@ variable "ssh_keys" {
}
}

variable "user_data" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a user_data field in the vsi variable below, so I do not think that we should have a separate variable here.

Is it possible to assign the correct user_data to the correct vsi object in the pattern instead? That way the override still works and we do not have duplicate variables.

@@ -40,6 +40,14 @@ variable "resource_tags" {
default = []
}

variable "user_data" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work well in quickstart, as we are hard-coding (in the override) the VSI configurations. If we still want to support user_data in quickstart, we should redesign this pattern a little bit so that user supplied user_data can be inserted into the override json. This does mean a bit of a redesign of this pattern where we would move the override from an input variable with default, and instead have it in the main.tf with variable placeholders. See the roks-quickstart/main.tf for an example.

@@ -146,6 +146,14 @@ variable "vsi_per_subnet" {
default = 1
}

variable "user_data" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex validation that you added at the root level really belongs here at the solution level. If you are going to validate that the map keys here match entries in the vpcs list, then you want to do it here at the entry point, and maybe also at the module level of this solution.

Also the description needs to be more detailed explaining to the user what this map is supposed to be (with the key being a VPC name from the vpcs variable, and the data being the yaml).

There is something else to mention here: the user_data is usually in yaml format. We need to test that yaml inside an object still works correctly from all deployement types (terraform CLI, schematics, projects) and to make sure the yaml is valid by time it is applied to the VSI.

@@ -34,6 +34,7 @@ module "landing_zone" {
teleport_config_data = local.env.teleport_config
teleport_vsi = local.env.teleport_vsi
vpc_placement_groups = local.env.vpc_placement_groups
user_data = var.user_data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated in the root level variables file, I don't think this should be its own separate input variable, as this property already exists within the VSI input map.

Instead, your new input variable for the pattern should be used to set the existing user_data property for the individual VSI entries in that map, somewhere in the config.tf: https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone/blob/main/patterns/vsi/module/config.tf#L85

@@ -33,6 +33,7 @@ module "dynamic_values" {
skip_kms_kube_s2s_auth_policy = var.skip_kms_kube_s2s_auth_policy
skip_all_s2s_auth_policies = var.skip_all_s2s_auth_policies
atracker_cos_bucket = var.atracker.add_route == true ? var.atracker.collector_bucket_name : null
user_data = var.user_data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will not be needed if you assign the user_data to the VSI object out in the pattern level as suggested.

@Aashiq-J
Copy link
Member Author

/run pipeline

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.

3 participants