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

fix: changes validation of empty provider credentials from Error to Warning #1501

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

AgustinBettati
Copy link
Member

@AgustinBettati AgustinBettati commented Oct 2, 2023

Description

Jira ticket: INTMDB-1127
GH issue: #1483

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

Found limitations when trying to define an acceptance test to verify warning is correctly returned:

Manual testing verification

TF config with no environment variables defined:

provider "mongodbatlas" {
  base_url = "https://cloud-dev.mongodb.com/"
}

resource "mongodbatlas_project" "test" {
  name  			 = "some-name"
  org_id 			 = "<ORG-ID>"
}

terraform plan

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set
│ 
│   with provider["registry.terraform.io/mongodb/mongodbatlas"],
│   on main.tf line 11, in provider "mongodbatlas":
│   11: provider "mongodbatlas" {
│ 
│ (and one more similar warning elsewhere)
╵
╷
│ Warning: error in configuring the provider.
│ 
│   with provider["registry.terraform.io/mongodb/mongodbatlas"],
│   on main.tf line 11, in provider "mongodbatlas":
│   11: provider "mongodbatlas" {
│ 
│ either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set

terraform apply

mongodbatlas_project.test: Creating...
╷
│ Warning: either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set
│ 
│   with provider["registry.terraform.io/mongodb/mongodbatlas"],
│   on main.tf line 11, in provider "mongodbatlas":
│   11: provider "mongodbatlas" {
│ 
│ (and one more similar warning elsewhere)
╵
╷
│ Warning: error in configuring the provider.
│ 
│   with provider["registry.terraform.io/mongodb/mongodbatlas"],
│   on main.tf line 11, in provider "mongodbatlas":
│   11: provider "mongodbatlas" {
│ 
│ either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set
╵
╷
│ Error: error creating Project: %s
│ 
│   with mongodbatlas_project.test,
│   on main.tf line 15, in resource "mongodbatlas_project" "test":
│   15: resource "mongodbatlas_project" "test" {
│ 
│ POST https://cloud-dev.mongodb.com/api/atlas/v1.0/groups: 401 (request "") You are not authorized for this resource.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/framework/validator 68%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util 20%
Summary 3% (279 / 10575)

@AgustinBettati AgustinBettati marked this pull request as ready for review October 2, 2023 10:19
@AgustinBettati AgustinBettati requested a review from a team as a code owner October 2, 2023 10:19
Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AgustinBettati AgustinBettati merged commit cefc71a into master Oct 2, 2023
23 checks passed
@AgustinBettati AgustinBettati deleted the INTMDB-1127 branch October 2, 2023 12:21
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.

None yet

3 participants