feat: Remove call data ssm parameter when ami id is specified #351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#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.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