Closed Kostoprav19 closed 3 months ago
This is expected behavior with how terraform handles state. You could try terraform apply -refresh-only
, see the documentation here.
@mega-alex unfortunately it does not work in this case. Here is my example in Staging Portal where all resources where removed.
terraform apply -var-file test-config.tfvars -refresh-only -auto-approve
data.aws_secretsmanager_secret.megaport: Reading...
data.aws_secretsmanager_secret.megaport: Read complete after 0s [id=arn:aws:secretsmanager:eu-central-1:893677514652:secret:megaport-dev-EMVzzv]
data.aws_secretsmanager_secret_version.megaport: Reading...
data.aws_secretsmanager_secret_version.megaport: Read complete after 0s [id=arn:aws:secretsmanager:eu-central-1:893677514652:secret:megaport-dev-EMVzzv|AWSCURRENT]
data.megaport_location.this: Reading...
data.megaport_location.this: Read complete after 9s [name=Interxion FRA6]
megaport_port.ipxgrx: Refreshing state...
data.megaport_partner.aws_port: Reading...
data.megaport_partner.internet: Reading...
megaport_mve.fortigate: Refreshing state...
data.megaport_partner.internet: Read complete after 6s
data.megaport_partner.aws_port: Still reading... [10s elapsed]
╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "tags" but a value was found in file "test-config.tfvars". If you meant to use this value, add a "variable" block to the configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide certain "global" settings to all configurations in your organization. To reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Error: Error Reading port
│
│ with megaport_port.ipxgrx,
│ on main.tf line 2, in resource "megaport_port" "ipxgrx":
│ 2: resource "megaport_port" "ipxgrx" {
│
│ Could not read port with ID 8eabde19-929f-436b-b9cc-7f36eb8fbd2c: GET https://api-staging.megaport.com/v2/product/8eabde19-929f-436b-b9cc-7f36eb8fbd2c: 400 (trace_id "f02587d7cde8ab088cb4cd24f0187d0b") Could not find a service with UID = 8eabde19-929f-436b-b9cc-7f36eb8fbd2c
╵
╷
│ Error: Error Reading MVE
│
│ with megaport_mve.fortigate,
│ on main.tf line 12, in resource "megaport_mve" "fortigate":
│ 12: resource "megaport_mve" "fortigate" {
│
│ Could not read MVE with ID a59bbe09-a36c-4b08-b654-e7dbb4fc13e7: GET https://api-staging.megaport.com/v2/product/a59bbe09-a36c-4b08-b654-e7dbb4fc13e7: 400 (trace_id "10bea7d13d9ef1e98fbf5110e684f0b7") Could not find a service with UID = a59bbe09-a36c-4b08-b654-e7dbb4fc13e7
The PR waiting on an API change to go in, but after that this should work and recreate resources that are missing in the staging environment.
Hello!
I am trying to create CD pipeline that will test Terraform code in Megaport Staging environment on Merge request. Megaport Staging environment is overwritten every 24 hours and synchronized with the production environment. So any changes that were deployed and saved in Terraform state are deleted. https://docs.megaport.com/troubleshooting/staging/
code that I am running
My expectation is that when Terraform plan detects that resources are gone it will not fail but will try to recreate them (as Terraform is declarative infrastructure management tool).
But instead I get error while running terraform plan