atlassian / terraform-provider-artifactory

Terraform provider to manage Artifactory
Apache License 2.0
89 stars 42 forks source link

Please publish this plugin to the terraform registry. #95

Closed TonyLovesDevOps closed 3 years ago

TonyLovesDevOps commented 3 years ago

Community Note

Description

This is a valuable provider for managing artifactory with terraform. The main complaint I have is that setting it up for all users is a hassle, given the manual installation of the provider plugin. It would be fantastic if this provider was published to the official terraform registry so it could be easily installed from there.

New or Affected Resource(s)

N/A

Potential Terraform Configuration

If this was published to the registry, using this provider would be as simple as putting the below code in your versions.tf file and running terraform init:

terraform {
  required_version = ">= 0.13"
  required_providers {
    artifactory = {
      source = "atlassian/artifactory"
      version = "~> 2.1"
    }
  }
}

As it stands now, I wrote a simple shell script which everyone who wants to use this provider needs to run:

#!/usr/bin/env bash

PLUGIN_VERSION=2.1.0
OS_ARCH=$(uname -sm | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
ARTIFACT_URL="https://github.com/atlassian/terraform-provider-artifactory/releases/download/v${PLUGIN_VERSION}/terraform-provider-artifactory_${PLUGIN_VERSION}_${OS_ARCH}.tar.gz"
PLUGIN_DIR="${HOME}/.terraform.d/plugins/localhost/local/artifactory/${PLUGIN_VERSION}/${OS_ARCH/x86_64/amd64}" # Terraform expects 'amd64' instead of 'x86_64' in the plugin directory name

# Make backup of ~/.terraformrc if one exists
if [ -f "${HOME}/.terraformrc" ]; then
  echo "Making backup of ~/.terraformrc before overwriting it"
  mv ~/.terraformrc ~/.terraformrc.bak.$(date '+%Y-%m-%dT%H:%M:%S%z')
fi

cat > ~/.terraformrc <<EOF
provider_installation {
  filesystem_mirror {
    path    = "$HOME/.terraform.d/plugins"
    include = ["localhost/*/*"]
  }
  direct {
    exclude = ["localhost/*/*"]
    include = ["*/*"]
  }
}
EOF

mkdir -p "${PLUGIN_DIR}"
wget --quiet "$ARTIFACT_URL" -O "${PLUGIN_DIR}/terraform-provider-artifactory.tar.gz"
tar zxf "${PLUGIN_DIR}/terraform-provider-artifactory.tar.gz" -C "${PLUGIN_DIR}"
chmod +x "${PLUGIN_DIR}/terraform-provider-artifactory"
echo "Provider installed; now run 'terraform init' to get set up"

References

peters95 commented 3 years ago

This has been published via JFrog to the Terraform registry. Not migrating Github issue.

TonyLovesDevOps commented 3 years ago

@peters95 That's awesome news, thank you! I was able to migrate to the official provider with zero issues. šŸ¦„