CircleCI-Public / terraform-orb

Deploy your infrastructure via a CircleCI pipeline using the Terraform orb. Integrate Infrastructure-as-Code (IaC) to help provision and manage any cloud, infrastructure, or service of your choice.
https://circleci.com/orbs/registry/orb/circleci/terraform
MIT License
10 stars 44 forks source link

Command terraform/install requires sudo, which is missing #23

Closed LaurentEscalier closed 3 years ago

LaurentEscalier commented 3 years ago

Orb Version

1.2.0

Describe the bug

When using the terraform/install command to install a specific version of Terraform, the command fails executing sudo mv terraform /usr/local/bin with the following error: /bin/sh: sudo: not found.

To Reproduce

  1. Use the circleci/terraform@1.2.0 orb in your pipeline
  2. Setup a job running with executor terraform/default
  3. Add the terraform/install command to the job
  4. Schedule a pipeline run
  5. Observer your terraform job failing at the terraform/install step

Expected behavior

EITHER The terraform/default execution environment is configured to support the execution of the terraform/install command.

OR The orb documentation mentions the additional steps required to prepare the execution environment for the execution of the terraform/install command.

Additional context

version: 2.1

orbs:
  terraform: circleci/terraform@1.2.0

jobs:
  # Terraform
  deploy_infrastructure:
    executor: terraform/default
    working_directory: ~/my-repository/infrastructure
    steps:
      - attach_workspace:
          name: Attach workplace from previous job(s)
          at: ~/my-repository
      - terraform/install:
          terraform_version: 0.13.5
gmemstr commented 3 years ago

If you're leveraging the default executor, you likely don't need to install terraform as well - if you need a specific version, you should pass that through to the executor or use another Docker image :)

version: 2.1

orbs:
  terraform: circleci/terraform@1.2.0

jobs:
  # Terraform
  deploy_infrastructure:
    executor:
      name: terraform/default
      image: hashicorp/terraform:0.13.5
    working_directory: ~/my-repository/infrastructure
    steps:
      - attach_workspace:
          name: Attach workplace from previous job(s)
          at: ~/my-repository
LaurentEscalier commented 3 years ago

Thanks @gmemstr ! That solves my problem :)