Skip to content

Publish is not executed before deploy is executed #21522

Open
@Nishikoh

Description

@Nishikoh

Describe the bug
Publish is not executed before deploy is executed. I thought that the docker image would be published if the terraform code contained docker dependencies when performing experimental-deploy. However, contrary to my expectations, the publish was not executed.

Pants version
2.22.0

OS
Ubuntu 22.04

Additional info

#pants.toml
[GLOBAL]
pants_version = "2.22.0"
backend_packages = [
  "pants.backend.build_files.fmt.ruff",
  "pants.backend.docker",
  "pants.backend.experimental.terraform",
  "pants.backend.python",
]

[python]
interpreter_constraints = ["==3.11.*"]
# main.tf
terraform {
  backend "local" {
    path = "/tmp/tfstate/baz.tfstate"
  }
}

provider "random" {
  version = "3.6.2"
}

resource "random_id" "id" {
  byte_length = 7
}
# BUILD
terraform_module(name="main")
terraform_deployment(name="deploy", root_module=":main", dependencies=[":app-docker"])

docker_image(
  name="app-docker",
  registries=[
        "ghcr.io",
  ],
  repository="<MY USER NAME>/pants-deploy-example",
  image_tags=["latest"],
  instructions=[
    "FROM alpine",
    "RUN echo 'hello world' > /hello.txt",
  ]
)
# log
$ pants experimental-deploy --experimental-deploy-publish-dependencies :deploy 
22:16:13.67 [INFO] Deploying targets...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # random_id.id will be created
  + resource "random_id" "id" {
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 7
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: Version constraints inside provider configuration blocks are deprecated
│ 
│   on main.tf line 14, in provider "random":
│   14:   version = "3.6.2"
│ 
│ Terraform 0.13 and earlier allowed provider version constraints inside the provider configuration block, but that is now deprecated and will be removed
│ in a future version of Terraform. To silence this warning, move the provider version constraint into the required_providers block.
╵

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

random_id.id: Creating...
random_id.id: Creation complete after 0s [id=dzju5Fqrzw]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

✓ infra/terraform/app/baz:deploy deployed

The publish log does not appear to be flowing.

https://github.com/grihabor/pants/blob/dd11c333e71976bb135f1b75b3abd26e27959bd2/src/python/pants/core/goals/deploy.py#L214

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions