bachue / terraform-provider-qiniu

Terraform Provider for Qiniu Cloud

Home Page:http://developer.qiniu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Provider for Qiniu Cloud

==================

Qiniu Cloud

Requirements

  • Terraform 0.12.x
  • Go 1.12 (to build the provider plugin)

Building The Provider

Clone repository

$ git clone git@github.com:qiniu/terraform-provider-qiniu.git --recurse-submodules

Enter the provider directory and build the provider

$ cd terraform-provider-qiniu
$ make

Install the provider

mkdir -p ~/.terraform.d/plugins
mv bin/terraform-provider-qiniu ~/.terraform.d/plugins

Using the Provider

# Configure Qiniu Account
provider "qiniu" {
  access_key = "<Qiniu Access Key>"
  secret_key = "<Qiniu Secret Key>"
}

# Create Qiniu Bucket
resource "qiniu_bucket" "basic_bucket" {
  name      = "basic-test-terraform-1"  # Bucket Name
  region_id = "z0"                      # Bucket Region, "z0" means East China
  private   = false                     # Public bucket
}

# Create Qiniu Object
resource "qiniu_bucket_object" "basic_object" {
  bucket    = "basic-test-terraform-1"  # Bucket Name
  key       = "qiniu-key"               # File Key
  source    = "/path/to/file"           # File Path to upload
}

# Qiniu Buckets Data Source
data "qiniu_buckets" "z1" {
  name_regex = "^bucket-"
  region_id = "z1"
}

# Qiniu Buckets Objects Data Source
data "qiniu_buckets_objects" "all" {
  bucket = "basic-test-terraform-1"
}

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.12+ is required).

To compile the provider, run make. This will build the provider and put the provider binary in the bin/ directory.

$ make
...
$ bin/terraform-provider-qiniu
...

In order to test the provider, you can copy .env.example to .env, and edit the .env file

QINIU_ACCESS_KEY=<Qiniu Access Key>
QINIU_SECRET_KEY=<Qiniu Secret Key>
TF_ACC=1

And then simply run

make test

About

Terraform Provider for Qiniu Cloud

http://developer.qiniu.com

License:Mozilla Public License 2.0


Languages

Language:Go 99.6%Language:Makefile 0.4%