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 output image id used in launch template #1676

Merged
merged 4 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/runners/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ output "launch_template" {
value = aws_launch_template.runner
}

output "image_id" {
Copy link
Member

Choose a reason for hiding this comment

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

Looks no reason to output, can you remove this aoput. Used image_id is part of the launch templates whic is already outputed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We output the launch template but the launch template doesn't expose anything of its settings so we need to output them as well if we want them exposed? https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template#attributes-reference Apologies if it does, I'm somewhat new to Terraform still.

Copy link
Member

Choose a reason for hiding this comment

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

No there is no need to output the image_id in this way, it is already outputted as part of the object launch_template., see

value = data.aws_ami.runner.id
}

output "role_runner" {
value = aws_iam_role.runner
}
Expand Down
18 changes: 10 additions & 8 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
output "runners" {
value = {
launch_template_name = module.runners.launch_template.name
launch_template_id = module.runners.launch_template.id
launch_template_version = module.runners.launch_template.latest_version
lambda_up = module.runners.lambda_scale_up
lambda_down = module.runners.lambda_scale_down
role_runner = module.runners.role_runner
role_scale_up = module.runners.role_scale_up
role_scale_down = module.runners.role_scale_down
launch_template_name = module.runners.launch_template.name
launch_template_id = module.runners.launch_template.id
launch_template_version = module.runners.launch_template.latest_version
launch_template_ami_id = module.runners.launch_template.latest_version
launch_template_image_id = module.runners.image_id
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
launch_template_image_id = module.runners.image_id
launch_template_image_id = module.runners.launch_template.image_id

Copy link
Contributor Author

@toast-gear toast-gear Feb 3, 2022

Choose a reason for hiding this comment

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

For my benefit how can I tell what is already output? I thought it was a case of looking at the attribute references for a given resource? So in this case launch_template.id and launch_template.latest_version are both documented attribute references, how can I tell image_id is one without just trying it?

Copy link
Member

Choose a reason for hiding this comment

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

Don't have a solid answer. One thing you can do is check state. But agree it is not always very clear what is exported.

lambda_up = module.runners.lambda_scale_up
lambda_down = module.runners.lambda_scale_down
role_runner = module.runners.role_runner
role_scale_up = module.runners.role_scale_up
role_scale_down = module.runners.role_scale_down
}
}

Expand Down