简体   繁体   中英

How to provision infrastructure in a local zone using terraform?

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.

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 su.net in the LZ enabled uzing aws_su.net

  3. Create instance in the su.net using aws_instance .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM