Terraform level 1 exercise 9

I’m creating the EBS using terraform, but the lab fails with the message that the EBS wasn’t created using terraform, but it was.

Hi @matheus.rossi,

Could you please share more screenshot or main.tf file content? I’ve just checked it and it’s worked properly from my end.
image

Hi @raymond.baoly , I appreciate your reply.

In my post, I’ve attached the screenshot with the main.tf file. I’ve tried 2 times, both with the same error.

The error occurs for the third time. here is my .tfstate

{
  "version": 4,
  "terraform_version": "1.11.0",
  "serial": 1,
  "lineage": "3a6f61a7-e667-e607-6ff3-3de24c8b9272",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "aws_ebs_volume",
      "name": "xfusion-volume",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:us-east-1::volume/vol-9fce0e5fa0ce1f758",
            "availability_zone": "",
            "encrypted": false,
            "final_snapshot": false,
            "id": "vol-9fce0e5fa0ce1f758",
            "iops": 3000,
            "kms_key_id": "",
            "multi_attach_enabled": false,
            "outpost_arn": "",
            "size": 2,
            "snapshot_id": "",
            "tags": {
              "name": "xfusion-volume"
            },
            "tags_all": {
              "name": "xfusion-volume"
            },
            "throughput": 0,
            "timeouts": null,
            "type": "gp3"
          },
          "sensitive_attributes": [],
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjMwMDAwMDAwMDAwMH19"
        }
      ]
    }
  ],
  "check_results": null
}

The main.tf file:

resource "aws_ebs_volume" "xfusion-volume" {
  availability_zone = "us-east-1"
  size              = 2
  type              = "gp3"

  tags = {
    "name" = "xfusion-volume"
  }
}

regards.

Hi @matheus.rossi,

I tried again today and was still able to complete the task. Please see the screenshot below.

Hi,

The issue is that availability_zone was set to ‘us-east-1’, but it should be ‘us-east-1a’.

1 Like

Thanks, @raymond.baoly. Adjusting the availability_zone worked perfectly. From my understanding, the API should throw an error when trying to create a zonal resource using a region. In any case, I really appreciate your help!

Hi @matheus.rossi,

Yeah, it should normally throw an error, but I think the API automatically picks a default zone, like us-west-2a.

1 Like