Closed shawnsavour closed 1 year ago
This PR is included in version 5.3.0 :tada:
Hello,
I am recently trying to use this module and ran into this issue
Error: Missing required argument
with module.mattermost_standalone_ecs_instance.aws_instance.this[0],
on .terraform/modules/mattermost_standalone_ecs_instance/main.tf line 22, in resource "aws_instance" "this":
22: ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null)
"ami": one of `ami,launch_template` must be specified
It seems like it might be due to merging this PR. The reason I believe is that the ami variable is always getting set to null because data.aws_ssm_parameter.this[0].value
cannot be referenced. I removed the try block locally and get this error message
Error: Invalid index
on .terraform/modules/mattermost_standalone_ecs_instance/main.tf line 22, in resource "aws_instance" "this":
22: ami = coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value))
βββββββββββββββββ
β data.aws_ssm_parameter.this is empty tuple
The given key does not identify an element in this collection value: the collection has no elements.
I'm going to lock this pull request because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
350 Description:
Description
Create an ec2 instance without ssm permission with cause error.
This account or role can still create an instance in console.
The root cause is because this line of code in main.tf in line 9:
Request to make the call data aws_ssm_parameter optional, something like when ami is specified, then no need to call ssm parameter to get the ami id:
Because it coalesce the
var.ami
and thenonsensitive(data.aws_ssm_parameter.this[0].value))
, so we only need it whenvar.ami
is not specified. So it should be check for null when use data to call to ssm.β οΈ Note
Versions
Module version [Required]: 5.2.1
Terraform version: any version
Provider version(s): any version
Reproduction Code [Required]
Steps to reproduce the behavior:
Expected behavior
Create an instance without ssm parameter permission
Actual behavior
Cannot create instance because missing permission