Terraform InvalidVpcID.NotFound

I was previous using Tokyo as my first region, and I’m encountering a problem when I am working with new region (sa-east-1)

Although I have my VPC in sa-east-1, Terraform apply gives an error Error creating Security Group: InvalidVpcID.NotFound: The vpc ID 'vpc-HASH' does not exist. I checked I have the vpc in sa-east-1, but have no idea why Terraform is unable to find the vpc.

resource "aws_security_group" "common_eks_sg" {
  name        = "common-eks-sg"
  description = "Every EKS node is attached to this security group."
  vpc_id      = "vpc-HASH"

  tags = merge(local.common_tags, {
    Name = "common-eks-sg"

I also tried setting the region inside ~/.aws/config as sa-east-1, but resulted in no luck. Any suggestions or help?

In order to check which region terraform is using you could output the “current region”. Maybe you’ve set AWS_DEFAULT_REGION environment variable.

data "aws_region" "current" {}
output my region {
  value = data.aws_region.current.name
1 Like

You could also set the region in the provider definition and check if that fixes the issue:

# Configure the AWS Provider
provider "aws" {
  region = "sa-east-1"