Terraform Lavel 1 Exercise 10

Following is my code in main.tf:

resource "aws_ebs_volume" "k8s_volume" {
  availability_zone = "us-east-1a"
  size              = 5
  type              = "gp2"

  tags = {
    Name        = "datacenter-vol"
  }
}

resource "aws_ebs_snapshot" "k8s_volume_clone" {
  volume_id = aws_ebs_volume.k8s_volume.id
  description = "Datacenter Snapshot"
  tags = {
    name = "datacenter-vol-ss"
  }
}

data "aws_ebs_snapshot" "k8s_volume_clone_snapshot_status" {
  depends_on = [aws_ebs_snapshot.k8s_volume_clone]
  most_recent = true
  owners = ["self"]
  filter {
    name = "snapshot-id"
    values = [aws_ebs_snapshot.k8s_volume_clone.id]
  }
  filter {
    name = "status"
    values = ["completed"]
  }
}

output "completed_k8s_volume_clone_snapshot" {
  value = data.aws_ebs_snapshot.k8s_volume_clone_snapshot_status.id
}

The state after executing terraform apply is as follows:

{
  "version": 4,
  "terraform_version": "1.11.0",
  "serial": 4,
  "lineage": "1d5d8ba0-ed8d-7cb7-b061-e7077c725199",
  "outputs": {
    "completed_k8s_volume_clone_snapshot": {
      "value": "snap-cba481ad893dbebd5",
      "type": "string"
    }
  },
  "resources": [
    {
      "mode": "data",
      "type": "aws_ebs_snapshot",
      "name": "k8s_volume_clone_snapshot_status",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:us-east-1::snapshot/snap-cba481ad893dbebd5",
            "data_encryption_key_id": "",
            "description": "Datacenter Snapshot",
            "encrypted": false,
            "filter": [
              {
                "name": "snapshot-id",
                "values": [
                  "snap-cba481ad893dbebd5"
                ]
              },
              {
                "name": "status",
                "values": [
                  "completed"
                ]
              }
            ],
            "id": "snap-cba481ad893dbebd5",
            "kms_key_id": "",
            "most_recent": true,
            "outpost_arn": "",
            "owner_alias": "",
            "owner_id": "000000000000",
            "owners": [
              "self"
            ],
            "restorable_by_user_ids": null,
            "snapshot_id": "snap-cba481ad893dbebd5",
            "snapshot_ids": null,
            "start_time": "2025-07-06T13:58:41Z",
            "state": "completed",
            "storage_tier": "",
            "tags": {
              "name": "datacenter-vol-ss"
            },
            "timeouts": null,
            "volume_id": "vol-d0cf86186c81da1bc",
            "volume_size": 5
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "managed",
      "type": "aws_ebs_snapshot",
      "name": "k8s_volume_clone",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:us-east-1::snapshot/snap-cba481ad893dbebd5",
            "data_encryption_key_id": "",
            "description": "Datacenter Snapshot",
            "encrypted": false,
            "id": "snap-cba481ad893dbebd5",
            "kms_key_id": "",
            "outpost_arn": "",
            "owner_alias": "",
            "owner_id": "000000000000",
            "permanent_restore": null,
            "storage_tier": "",
            "tags": {
              "name": "datacenter-vol-ss"
            },
            "tags_all": {
              "name": "datacenter-vol-ss"
            },
            "temporary_restore_days": null,
            "timeouts": null,
            "volume_id": "vol-d0cf86186c81da1bc",
            "volume_size": 5
          },
          "sensitive_attributes": [],
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
          "dependencies": [
            "aws_ebs_volume.k8s_volume"
          ]
        }
      ]
    },
    {
      "mode": "managed",
      "type": "aws_ebs_volume",
      "name": "k8s_volume",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:us-east-1::volume/vol-d0cf86186c81da1bc",
            "availability_zone": "us-east-1a",
            "encrypted": false,
            "final_snapshot": false,
            "id": "vol-d0cf86186c81da1bc",
            "iops": 0,
            "kms_key_id": "",
            "multi_attach_enabled": false,
            "outpost_arn": "",
            "size": 5,
            "snapshot_id": "",
            "tags": {
              "Name": "datacenter-vol"
            },
            "tags_all": {
              "Name": "datacenter-vol"
            },
            "throughput": 0,
            "timeouts": null,
            "type": "gp2"
          },
          "sensitive_attributes": [],
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjMwMDAwMDAwMDAwMH19"
        }
      ]
    }
  ],
  "check_results": null
}

I seem to be have done everything correctly, yet I get the following screen:

Is there something I am missing? Any help is appreciated.

Hi @noopurp123

To create the snapshot named datacenter-vol-ss, you should use the tag ‘Name’ (with a capital N), not ‘name’

1 Like

This is true for all resources. If you need to name them, it’s always tag Name

1 Like

That worked, thanks a lot

Got it, I was able to run it successfully. Thanks!