hashicorp / terraform-provider-docker

As part of our introduction to self-service publishing in the Terraform Registry, this copy of the provider has been archived, and ownership has been transferred to active maintainers in the community. Please see the new location on the Terraform Registry: https://registry.terraform.io/providers/kreuzwerker/docker/latest
https://registry.terraform.io/providers/kreuzwerker/docker/latest
Mozilla Public License 2.0
132 stars 91 forks source link

Docker provider fails to configure when it depends on resources attributes #250

Closed edgarpoce closed 4 years ago

edgarpoce commented 4 years ago

Summary

The provider fails to initialize if there's an auth config that contains a dependency to a resource. As a result the whole deployment fails.

My understanding is that providers must not fail early unless the error is unrecoverable.

When there's a dependency to a resource attribute then the provider should be able to ignore the error and take it into account when available.

If the provider fails early then the whole deployment fails before evaluating any resource because all providers are created before any other resource or data source.

Terraform Version

Terraform v0.12.23

Affected Resource(s)

The Docker provider is affecting all resources in this case

Terraform Configuration Files

provider "aws" {
  version = "~> 2.0"
  region = "us-east-1"
}

resource "aws_ssm_parameter" "host" {
  name  = "/test/host"
  type  = "String"
  value = "localhost:15000"
}

resource "aws_ssm_parameter" "username" {
  name  = "/test/username"
  type  = "String"
  value = "testuser"
}

resource "aws_ssm_parameter" "password" {
  name  = "/test/password"
  type  = "String"
  value = "testpwd"
}

provider "docker" {
  version = "2.7.0"
  registry_auth {
    address  = aws_ssm_parameter.host.value
    username = aws_ssm_parameter.username.value
    password = aws_ssm_parameter.password.value
  }
}  

data "docker_registry_image" "helloworld" {
  name = "${aws_ssm_parameter.host.value}/helloworld:1.0"
}

Expected Behavior

What should have happened?

The deployment above should work correctly given the credentials are correct and the image referenced by docker_registry_image is available in the registry

Actual Behavior

What actually happened?

The provider failed to configure which caused the failure of the full deployment

Error: Error loading registry auth config: Couldn't find registry config for 'https://' in file: /home/phipeeps/.docker/config.json

  on main.tf line 24, in provider "docker":
  24: provider "docker" {

Steps to Reproduce

terraform apply

References

mavogel commented 4 years ago

closed by #251