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

Enable Project key under Paths for the /api/plan api #5087

Open
1 task
dimisjim opened this issue Nov 12, 2024 · 1 comment
Open
1 task

Enable Project key under Paths for the /api/plan api #5087

dimisjim opened this issue Nov 12, 2024 · 1 comment
Labels
feature New functionality/enhancement

Comments

@dimisjim
Copy link
Contributor

dimisjim commented Nov 12, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

I would like to be able to call the atlantis /api/plan by specifying the project defined in the repo level yaml, instead of just either one of Directory or Workspace as mentioned at: https://www.runatlantis.io/docs/api-endpoints#post-api-plan

Describe the solution you'd like

Have parity in the plan api with the options provided in the repo atlantis config yaml, which defines the projects and workflows like this:

version: 3
projects:
- name: coolproject-dev
  workflow: coolproject-dev
  dir: coolproject
  autoplan:
    when_modified: ["*.tf", "env-vars/dev.tfvars"]

....

workflows:
  coolproject-dev:
    plan:
      steps:
      - init:
          extra_args: ["-backend-config=backend-configs/dev.hcl", "-reconfigure", "-upgrade"]
      - plan:
          extra_args: ["-var-file=env-vars/dev.tfvars"]
    apply:
      steps:
      - run: |
          ...

so that we can then be able to run:

http -b POST https://<atlantis-host>/api/plan \ 
    X-Atlantis-Token:<...> \
    <<<'{ "Repository": "coolorg/coolrepo", "Ref": "main", "Type": "Github", "Paths": [{"Directory": "coolproject"}, {"Project":"coolproject-dev"}]}'

Describe the drawbacks of your solution

Can't think of any

Describe alternatives you've considered

I've tried running the aforementioned command in the description of the solution section above, but I'm getting:

{
"error": "failed to build command: must specify project name: more than one project defined in 'atlantis.yaml' matched dir: 'coolproject' workspace: 'default'"
}

and if I only specify the Directory using the name of the project, I am getting:

{
    "Error": null,
    "Failure": "",
    "PlansDeleted": false,
    "ProjectResults": [
        {
            "ApplySuccess": "",
            "Command": 1,
            "Error": {
                "RepoRelDir": "coolproject-dev"
            },
            "Failure": "",
            "ImportSuccess": null,
            "PlanSuccess": null,
            "PolicyCheckResults": null,
            "ProjectName": "",
            "RepoRelDir": "ilayer-dev",
            "SilencePRComments": null,
            "StateRmSuccess": null,
            "SubCommand": "",
            "VersionSuccess": "",
            "Workspace": "default"
        }
    ]
}

and in the logs:

"caller":"terraform/terraform_client.go:293","msg":"trying to detect required version: Failed to read module directory: Module directory /root/.atlantis/repos/org/coolrepo/0/default/coolproject-dev does not exist or cannot be read."

I would like to use Atlantis for drift checking, I could use some other mechanism of course, until this is implemented

@dimisjim dimisjim added the feature New functionality/enhancement label Nov 12, 2024
@johnvandeweghe
Copy link

The source seems to have an undocumented Projects key in the request body it appears. It is a list of strings of project names to run. Does that solve your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants