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

Add optional tfe-token flag. Get working with 0.12. #419

Merged
merged 3 commits into from
Jan 10, 2019
Merged

Conversation

lkysow
Copy link
Member

@lkysow lkysow commented Jan 9, 2019

Add new --tfe-token flag for TFE backend.

The new flag takes in a Terraform Enterprise API token and attempts to
write a config file for that token to ~/.terraformrc on startup.
If the file already exists and its contents would change as a result of
us writing it, we error out.
This flag is useful if you're using the TFE backend for any of your
projects as that requires a .terraformrc file with a token for
authentication.

Don't add extra -var flags when using TF >= 0.12
In Terraform 0.12 and above, you aren't allowed to set -var foo=bar
flags unless the foo variable is actually defined in code. Previously,
we were setting the following variables:

  • atlantis_user
  • atlantis_repo
  • atlantis_repo_owner
  • atlantis_repo_name
  • atlantis_pull_num

Users could then use these variables if they wanted to, in their code.
The main use case was to name the assume role session in AWS:

provider "aws" {
  assume_role {
    role_arn     = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
    session_name = "${var.atlantis_user}-${var.atlantis_repo_owner}-${var.atlantis_repo_name}-${var.atlantis_pull_num}"
  }
}

This is longer possible in 0.12.

lkysow added 2 commits January 9, 2019 14:49
The new flag takes in a Terraform Enterprise API token and attempts to
write a config file for that token to ~/.terraformrc on startup.
If the file already exists and its contents would change as a result of
us writing it, we error out.
This flag is useful if you're using the TFE backend for any of your
projects as that requires a .terraformrc file with a token for
authentication.
@lkysow lkysow force-pushed the tfe-token branch 2 times, most recently from 46baf27 to 0f1d8ee Compare January 9, 2019 20:39
@codecov
Copy link

codecov bot commented Jan 9, 2019

Codecov Report

Merging #419 into master will increase coverage by 0.01%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #419      +/-   ##
==========================================
+ Coverage   70.22%   70.23%   +0.01%     
==========================================
  Files          63       63              
  Lines        3902     3924      +22     
==========================================
+ Hits         2740     2756      +16     
- Misses        967      972       +5     
- Partials      195      196       +1
Impacted Files Coverage Δ
server/events/models/models.go 89.61% <ø> (ø) ⬆️
cmd/server.go 78.23% <ø> (ø) ⬆️
server/user_config.go 100% <ø> (ø) ⬆️
server/server.go 66.27% <100%> (ø) ⬆️
server/events/runtime/plan_step_runner.go 94.52% <100%> (+0.15%) ⬆️
server/events/terraform/terraform_client.go 74.32% <71.42%> (-1.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d2fd43...e0dcb5a. Read the comment docs.

In Terraform 0.12 and above, you aren't allowed to set -var foo=bar
flags unless the foo variable is actually defined in code. Previously,
we were setting the following variables:
- atlantis_user
- atlantis_repo
- atlantis_repo_owner
- atlantis_repo_name
- atlantis_pull_num

Users could then use these variables if they wanted to, in their code.
The main use case was to name the assume role session in AWS:

provider "aws" {
  assume_role {
    role_arn     = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
    session_name = "${var.atlantis_user}-${var.atlantis_repo_owner}-${var.atlantis_repo_name}-${var.atlantis_pull_num}"
  }
}

This is longer possible in 0.12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant