hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Bug]: deletion of upstreams in codeartifact is not complete #31092

Open suchakra-texada opened 1 year ago

suchakra-texada commented 1 year ago

Terraform Core Version

1.4.5

AWS Provider Version

3.75.2

Affected Resource(s)

No response

Expected Behavior

if an existing codeartifact upstream repository is deleted and its references in another repository is deleted from terraform and applied, the action should be complete.

Actual Behavior

We did not have any issue with npm and nuget upstreams, and we hadnt even created a maven upstream. But we discovered the issue with Maven/Gradle. The autogenerated maven-metadata.xml started showing:

A repository referenced in your upstream graph no longer exists. To fix this issue, use the UpdateRepository API with your new desired upstream configuration. Note that if an upstream repository was deleted and recreated using the same name, UpdateRepository must still be called to reference the new repository. This issue may be present in any repository in the upstream graph.

And of course builds were not working. So I had to actually call update-repository to register the deletion.

PS api-tests [master *]> aws codeartifact update-repository --domain myDomain --repository myRepoInUse
{
    "repository": {
        "name": "myRepoInUse",
        "administratorAccount": "111122223333",
        "domainName": "myDomain",
        "domainOwner": "111122223333",
        "arn": "arn:aws:codeartifact:us-east-1:111122223333:repository/myDomain/myRepoInUse",
        "description": "myRepoInUse component artifacts",
        "upstreams": [
            {
                "repositoryName": "npm-store"
            },
            {
                "repositoryName": "nuget-store"
            }
        ],
        "externalConnections": [],
        "createdTime": "2023-04-18T21:14:25.960000-04:00"
    }
}

PS api-tests [master *]> aws codeartifact update-repository --domain myDomain --repository myRepoInUse --upstreams []
{
    "repository": {
        "name": "myRepoInUse",
        "administratorAccount": "111122223333",
        "domainName": "myDomain",
        "domainOwner": "111122223333",
        "arn": "arn:aws:codeartifact:us-east-1:111122223333:repository/myDomain/myRepoInUse",
        "description": "myRepoInUse component artifacts",
        "upstreams": [],
        "externalConnections": [],
        "createdTime": "2023-04-18T21:14:25.960000-04:00"
    }
}

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

module "internal-codeartifact" {
  source      = "../../../../modules/core/codeartifact-repository"
  name        = "internal"
  domain      = local.domain
  description = "Internal component artifacts"
upstreams = [...]
  island      = "shared"
}

resource "aws_codeartifact_repository" "repository" {
  repository  = var.name
  domain      = var.domain
  description = var.description

  dynamic "upstream" {
    for_each = var.upstreams
    content {
      repository_name = upstream.value
    }
  }
  tags = merge(local.universal_tags, var.additional_tags)
}

after creating them, get rid of the upstreams....

Steps to Reproduce

  1. Create repo, upstream repo for npm and nuget
  2. delete the upstream repo.
  3. check the value returned by aws codeartifact update-repository --domain myDomain --repository myRepoInUse

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue