puppetlabs / puppetlabs-pecdm

Puppet Bolt driven fusion of puppetlabs/peadm and Terraform.
Apache License 2.0
14 stars 18 forks source link

pecdm::provision fails to reprovision a deleted VM in aws #114

Open jessereynolds opened 7 months ago

jessereynolds commented 7 months ago

Describe the Bug

pecdm::provision should handle the case where a VM has been deleted but other resources are still instantiated such as the EC2 Key Pair. Currently the terraform::apply task errors as follows:

Failed on localhost:

  Error: importing EC2 Key Pair (pe_adm_a7d5bf): InvalidKeyPair.Duplicate: The keypair already exists
    status code: 400, request id: 2d8e22fe-9472-4999-8367-3714c3987298

    with module.instances.aws_key_pair.pe_adm,
    on modules/instances/main.tf line 54, in resource "aws_key_pair" "pe_adm":
    54: resource "aws_key_pair" "pe_adm" {

  Error: creating EC2 VPC: operation error EC2: CreateVpc, https response error StatusCode: 400, RequestID: 305d4e97-817c-4a45-810f-e65afd880897, api error VpcLimitExceeded: The maximum number of VPCs has been reached.

    with module.networking.aws_vpc.pe[0],
    on modules/networking/main.tf line 23, in resource "aws_vpc" "pe":
    23: resource "aws_vpc" "pe" {

Failed on 1 target: localhost

Expected Behavior

Existing resources already present should not cause (re)provisioning failure

Steps to Reproduce

Environment

git show
commit f13a5abcc781804b77e4165f6079b2f194d2fee4 (HEAD -> main, origin/main, origin/HEAD)
Merge: 48bb621 82838da
Author: David Sandilands <david.sandilands@perforce.com>
Date:   Tue Oct 17 16:02:01 2023 +0100

terraform puppet module version from Puppetfile:

mod 'puppetlabs-terraform',
    git: 'https://github.com/puppetlabs/puppetlabs-terraform.git',
    ref: 'ce7b0070e7d7ec3b683df7dffb7fce745eca06e6'

Additional Context

N/A