Home > database >  How to provision infrastructure in a local zone using terraform?
How to provision infrastructure in a local zone using terraform?

Time:01-12

AWS recently introduced local zones (ap-south-1-del-1). I am trying to use the region to deploy an EC2 instance. I have enabled the region and the local zone in my AWS account.

This is my terraform provider file :-

provider "aws" {
  region = "ap-south-1-del-1"
}

terraform {
  required_version = "> 0.11"
  required_providers {
    aws = "~> 4.0"
  }
}

but i keep running into the following :-

 Error: error configuring Terraform AWS Provider: error validating provider credentials: 
 error calling sts:GetCallerIdentity: operation error STS: GetCallerIdentity, exceeded maximum 
 number of attempts, 9, https response error StatusCode: 0, RequestID: , request send failed, 
 Post "https://sts.ap-south-1-del-1.amazonaws.com/": dial tcp: lookup sts.ap-south-1-del- 
 1.amazonaws.com: no such host
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 1, in provider "aws":
│    1: provider "aws" {
│
╵

and this is my EC2 instance for anyone curious. Super basic.

resource "aws_instance" "web" {
  ami           = "ami-0ef82eeba2c7a0eeb"
  instance_type = "t2.micro"

  tags = {
    Name = "HelloWorld"
  }
}

Has anyone tried it? Is it supported? Thank you.

CodePudding user response:

You do not change the provider's region. It is still ap-south-1. To create EC2 instance in a LZ, you have to follow three steps:

  1. Enable a Local Zone using aws_ec2_availability_zone_group

  2. Create subnet in the LZ enabled uzing aws_subnet

  3. Create instance in the subnet using aws_instance.

CodePudding user response:

I think you need to update the provider version for aws to work with new local zones. You can go to official provider page and upgrade the version to a newer version for aws provider

  • Related