diff --git a/README.md b/README.md
index cdd8766f..9cc79d8d 100644
--- a/README.md
+++ b/README.md
@@ -265,6 +265,7 @@ No modules.
| Name | Description |
|------|-------------|
+| [ami](#output\_ami) | AMI ID that was used to create the instance. |
| [arn](#output\_arn) | The ARN of the instance |
| [capacity\_reservation\_specification](#output\_capacity\_reservation\_specification) | Capacity reservation specification of the instance |
| [iam\_instance\_profile\_arn](#output\_iam\_instance\_profile\_arn) | ARN assigned by AWS to the instance profile |
diff --git a/main.tf b/main.tf
index a13e6e00..8d7695d8 100644
--- a/main.tf
+++ b/main.tf
@@ -19,7 +19,7 @@ data "aws_ssm_parameter" "this" {
resource "aws_instance" "this" {
count = local.create && !var.create_spot_instance ? 1 : 0
- ami = try(coalesce(var.ami, data.aws_ssm_parameter.this[0].value), null)
+ ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null)
instance_type = var.instance_type
cpu_core_count = var.cpu_core_count
cpu_threads_per_core = var.cpu_threads_per_core
@@ -167,7 +167,7 @@ resource "aws_instance" "this" {
resource "aws_spot_instance_request" "this" {
count = local.create && var.create_spot_instance ? 1 : 0
- ami = try(coalesce(var.ami, data.aws_ssm_parameter.this[0].value), null)
+ ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null)
instance_type = var.instance_type
cpu_core_count = var.cpu_core_count
cpu_threads_per_core = var.cpu_threads_per_core
diff --git a/outputs.tf b/outputs.tf
index 45f42545..1fc2b80a 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -78,6 +78,11 @@ output "spot_instance_id" {
value = try(aws_spot_instance_request.this[0].spot_instance_id, "")
}
+output "ami" {
+ description = "AMI ID that was used to create the instance."
+ value = try(aws_instance.this[0].ami, aws_spot_instance_request.this[0].ami, "")
+}
+
################################################################################
# IAM Role / Instance Profile
################################################################################