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

Implement Terraform: Apply as a command #648

Open
radeksimko opened this issue May 24, 2021 · 1 comment · May be fixed by #700
Open

Implement Terraform: Apply as a command #648

radeksimko opened this issue May 24, 2021 · 1 comment · May be fixed by #700
Labels
enhancement New feature or request

Comments

@radeksimko
Copy link
Member

Problem Statement

Terraform allows the user to apply changes to their infrastructure via terraform apply, which is likely the most commonly used command.

Users would benefit from being able to apply changes directly from the editor.

Technical Details

The extension currently implements the following:

The difference in how each command is integrated relate to how the output/outcome is mappable to LSP and how it can be communicated to the user.

Expected User Experience

User is able to open a command palette and choose "Terraform: Apply", similar to how they can do that for terraform plan currently:

Screenshot 2021-05-24 at 12 11 46

Then user will be prompted to confirm the action via prompt.

Then the user will see the apply command executed in the VS Code terminal, similar to terraform plan:

Screenshot 2021-05-24 at 12 13 00

Proposal

Implement terraform apply as command executable from the command palette.

It may be easiest to just implement it initially so that it executes in the integrated terminal. We can later assess whether any integration with LS is useful.

@radeksimko radeksimko added the enhancement New feature or request label May 24, 2021
@rezaetezal
Copy link

I've been able to achieve something similar to what's being requested using tasks. We have a different workflow for our terraform and use some additional tooling which I actually use in my own Terraform workspace, but here is an example of how it could work if you use the bare terraform commands with no additional tools like terradactyl or envchain

    "version": "2.0.0",
    "tasks": [
        {
            "label": "0 terraform init",
            "type": "shell",
            "presentation": {
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "command": "terraform init",
            "problemMatcher": []
        },
        {
            "label": "1 terraform plan",
            "type": "shell",
            "presentation": {
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "command": "terraform plan",
            "problemMatcher": []
        },
        {
            "label": "2 terraform apply",
            "type": "shell",
            "presentation": {
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "command": "terraform apply",
            "problemMatcher": []
        },
        {
            "label": "3 terraform plan (destroy)",
            "type": "shell",
            "presentation": {
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "command": "terraform plan -destroy",
            "problemMatcher": []
        },
        {
            "label": "4 terraform destroy",
            "type": "shell",
            "presentation": {
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "command": "terraform destroy",
            "problemMatcher": []
        }
    ]
},

@kamilturek kamilturek linked a pull request Jul 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants