Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform not picking up provider details #3551

Closed
asmksf opened this issue Feb 27, 2018 · 5 comments · Fixed by #10981
Closed

terraform not picking up provider details #3551

asmksf opened this issue Feb 27, 2018 · 5 comments · Fixed by #10981
Labels
bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.
Milestone

Comments

@asmksf
Copy link

asmksf commented Feb 27, 2018

Hi there,

I am trying to create a vpc in our aws prod account and in main.tf we have

provider "aws" {
    region = "us-east-1"
   shared_credentials_file = "/Users/user-name/.aws/credentials"
   profile = "prod"

}

ERROR

Error: Error refreshing state: 2 error(s) occurred:

  • data.terraform_remote_state.infrastructure_prod: 1 error(s) occurred:

  • data.terraform_remote_state.infrastructure_prod: data.terraform_remote_state.infrastructure_prod: error loading the remote state: AccessDenied: Access Denied
    status code: 403, request id: 01524824E7FC9D7B, host id: UJL0U8azl+lgWJIlhtfa+3Nf9MEPyGTo301IJvPi7zks1gy922B3qoBAEAVc9jtpXnG8X2ZcQfU=

  • module.vpc.module.vpc.aws_default_route_table.default: 1 error(s) occurred:

  • module.vpc.module.vpc.aws_default_route_table.default: aws_default_route_table.default: Default Route table not found

Terraform Version

Run terraform -v to show the version
terraform -v
Terraform v0.11.3

  • provider.aws v1.10.0

main.tf

###
# This file declares all input and ouput variables
###

provider "aws" {
  region = "us-east-1"
  shared_credentials_file = "/Users/mkaja/.aws/credentials"
  profile = "prod"

}

terraform {
  required_version = "~> 0.11"

  # Modify the configuration accordingly
  backend "s3" {
      bucket = "bucket-name"
      encrypt = "true"
      key     = "infrastructure_states/us-east-1/vpc-name/terraform.tfstate"
      region  = "us-east-1"
    }
  }



data "terraform_remote_state" "infrastructure_prod" {
backend = "s3"

config {
bucket = "bucket-name"
key    = "infrastructure_states/us-east-1/infrastructure-prod/terraform.tfstate"
region = "us-east-1"
  profile = "prod"
}
}


variable "azs" {
  description = "A list of availability zones"
  type        = "list"
}
variable "cost_tags" {
  description = "A map of tags needed for cost tracking"
  type        = "map"
}
variable "default_ubuntu_ami" {
  description = "The default base Ubuntu AMI"
}
/*variable "infrastructure_nexus_sg" {
  description = "The security group id of the Nexus ELB."
}*/
variable "name" {
  description = "A prefix applied to all resources in the VPC, and it should match the name of the project"
}
variable "name_acronym" {
  description = "A shortened prefix applied to all resources that have strict length limit of the name"
}
variable "private_subnet_cidrs" {
  description = "A list of CIDR blocks for private subnets. Typically like <vpc_cidr_first_two_octet>.<even_number>.0/24. e.g. ['10.183.0.0/24', '10.183.2.0/24']"
  type        = "list"
}
variable "public_subnet_cidrs" {
  description = "A list of CIDR blocks for public subnets. Typically like <vpc_cidr_first_two_octet>.<odd_number>.0/24. e.g. ['10.183.1.0/24', '10.183.3.0/24']"
  type        = "list"
}
variable "region" {
  description = "The region the resources should be created in"
  default     = "us-east-1"
}
variable "vpc_cidr" {
  description = "A CIDR block for the VPC, typically with a subnet mask of /16"
}
variable "vpc_key_name" {
  description = "Name of the Key pair to be used to log into the instances"
}

Outputs

output "bastion_sg" {
  value = "${module.vpc.bastion_security_group}"
}
output "bastion_sg_name" {
  value = "${module.vpc.bastion_sg_name}"
}
output "common_sg" {
  value = "${module.vpc.vpc_common_sg}"
}
output "common_sg_name" {
  value = "${module.vpc.vpc_common_sg_name}"
}
output "vpc_key_name" {
  value = "${var.vpc_key_name}"
}
output "vpc_name" {
  value = "${var.name}"
}
output "vpc_id" {
  value = "${module.vpc.vpc_id}"
}
output "vpc_region" {
  value = "${var.region}"
}
@Ninir Ninir added bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS. labels Feb 28, 2018
@asmksf
Copy link
Author

asmksf commented Mar 2, 2018

any update on this?

@gangofnuns
Copy link

I have a similar problem. Same error.

Seems to have shown up after manually deleting the vpc and trying to recreate in terraform.

bflad added a commit that referenced this issue Nov 22, 2019
…ehavior when Default Route Table is missing

Reference: #398
Reference: #3551
Reference: #9009

Previously on creation, if the Default Route Table was incorrectly configured or non-existent, the resource would unexpectedly attempt to remove itself from the Terraform state and propose recreation immediately. Prior to Terraform 0.12, this behavior was errantly acceptable. In Terraform 0.12, resources are required to return Terraform state about themselves during creation or throw an error explaining why the creation failed.

Previously on read, if the Default Route Table was missing (e.g. due to the VPC being deleted outside Terraform), the resource would return an error and require operators to manually perform a `terraform state rm` command instead of proposing resource recreation.

Output from new acceptance testing before code updates:

```
--- FAIL: TestAccAWSDefaultRouteTable_basic (20.02s)
    testing.go:628: Step 0, expected error:

        errors during apply: Provider produced inconsistent result after apply: When applying changes to aws_default_route_table.foo, provider "aws" produced an unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own issue tracker.

        To match:

        TBD

--- FAIL: TestAccAWSDefaultRouteTable_disappears_Vpc (20.27s)
    testing.go:635: Step 0 error: errors during follow-up refresh:

        Error: Default Route table not found

    testing.go:696: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: Default Route table not found

        State: <nil>
```

Output from acceptance testing after code updates:

```
--- PASS: TestAccAWSDefaultRouteTable_disappears_Vpc (20.46s)
--- PASS: TestAccAWSDefaultRouteTable_basic (40.99s)
--- PASS: TestAccAWSDefaultRouteTable_vpc_endpoint (49.71s)
--- PASS: TestAccAWSDefaultRouteTable_swap (73.89s)
--- PASS: TestAccAWSDefaultRouteTable_Route (87.09s)
--- PASS: TestAccAWSDefaultRouteTable_Route_TransitGatewayID (374.87s)
```
@bflad bflad added this to the v2.40.0 milestone Nov 25, 2019
bflad added a commit that referenced this issue Nov 25, 2019
…ehavior when Default Route Table is missing (#10981)

Reference: #398
Reference: #3551
Reference: #9009

Previously on creation, if the Default Route Table was incorrectly configured or non-existent, the resource would unexpectedly attempt to remove itself from the Terraform state and propose recreation immediately. Prior to Terraform 0.12, this behavior was errantly acceptable. In Terraform 0.12, resources are required to return Terraform state about themselves during creation or throw an error explaining why the creation failed.

Previously on read, if the Default Route Table was missing (e.g. due to the VPC being deleted outside Terraform), the resource would return an error and require operators to manually perform a `terraform state rm` command instead of proposing resource recreation.

Output from new acceptance testing before code updates:

```
--- FAIL: TestAccAWSDefaultRouteTable_basic (20.02s)
    testing.go:628: Step 0, expected error:

        errors during apply: Provider produced inconsistent result after apply: When applying changes to aws_default_route_table.foo, provider "aws" produced an unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own issue tracker.

        To match:

        TBD

--- FAIL: TestAccAWSDefaultRouteTable_disappears_Vpc (20.27s)
    testing.go:635: Step 0 error: errors during follow-up refresh:

        Error: Default Route table not found

    testing.go:696: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: Default Route table not found

        State: <nil>
```

Output from acceptance testing after code updates:

```
--- PASS: TestAccAWSDefaultRouteTable_disappears_Vpc (20.46s)
--- PASS: TestAccAWSDefaultRouteTable_basic (40.99s)
--- PASS: TestAccAWSDefaultRouteTable_vpc_endpoint (49.71s)
--- PASS: TestAccAWSDefaultRouteTable_swap (73.89s)
--- PASS: TestAccAWSDefaultRouteTable_Route (87.09s)
--- PASS: TestAccAWSDefaultRouteTable_Route_TransitGatewayID (374.87s)
```
@bflad
Copy link
Contributor

bflad commented Nov 25, 2019

The adjustment of the resource to propose resource recreation in this scenario instead of an error has been merged and will release with version 2.40.0 of the Terraform AWS Provider this week.

@ghost
Copy link

ghost commented Nov 27, 2019

This has been released in version 2.40.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.
Projects
None yet
4 participants