项目作者: Private-Universe

项目描述 :
IT Glue Terraform Provider
高级语言: Go
项目地址: git://github.com/Private-Universe/terraform-provider-itglue.git
创建时间: 2020-11-16T22:29:49Z
项目社区:https://github.com/Private-Universe/terraform-provider-itglue

开源协议:Mozilla Public License 2.0

下载


Terraform Provider IT Glue

This provider is in extremely early stages. Use at your own risk.

It uses our incomplete Go IT Glue API wrapper for the backend.

Table of contents

Installation

Run the following command to build the provider or download a GitHub release.

  1. go build -o terraform-provider-itglue.exe

Move the executable to the directory below (replace x.x.x with the appropriate version number)

  1. %AppData%\terraform.d\plugins\privateuniverse.com.au\pu\itglue\x.x.x\windows_amd64\

Upgrading

In the %AppData%\terraform.d\plugins\privateuniverse.com.au\pu\itglue\ directory, add a new folder structure for the new version of the provider.

In your Terraform directory, bump up the version number of the provider and run the following command:

  1. terraform init -upgrade

Setup

In your Terraform configuration, add the provider (note: AWS is not required)

  1. terraform {
  2. required_providers {
  3. aws = {
  4. source = "hashicorp/aws"
  5. version = "3.8.0"
  6. }
  7. itglue = {
  8. source = "privateuniverse.com.au/pu/itglue"
  9. version = "0.1.18"
  10. }
  11. }
  12. }

Add the IT Glue API key to the provider

  1. provider "itglue" {
  2. api_key = local.itglue_api_key.key
  3. }

It is recommended to provide the API key from something like AWS Parameter Store

Example providing API key using AWS Parameter Store

In AWS Parameter Store as a secure string with the name /company/itglue/apikey:

  1. {
  2. "key":"ITG.exampleapikey.longstringofrandomcharacters"
  3. }

In your locals:

  1. data "aws_ssm_parameter" "itglueapikey" {
  2. name = "/company/itglue/apikey"
  3. }
  4. locals {
  5. itglue_api_key = jsondecode(
  6. data.aws_ssm_parameter.itglueapikey.value
  7. )
  8. }

Use local.itglue_api_key.key where needed.

Example Usage

Currently only the below are supported.

Refer to the official IT Glue API documentation for valid fields. Please submit an issue or pull request if something is not supported.

Flexible assets

For flexible assets, you need to provide traits, organization_id and flexible_asset_type_id.

The traits are based upon how your flexible asset is set up and can be any string.

You also need to provide the flexible asset type ID with the traits and the organization ID under which you want the flexible asset listed.

  1. resource "itglue_flexible_asset" "example_server" {
  2. traits = {
  3. company-name = var.tag_company_name
  4. admin-username = "test"
  5. url = "https://example.com"
  6. internal-ip-address = "1.1.1.1"
  7. external-ip-address = "1.1.1.2"
  8. link-to-organisation = 123456
  9. license-key = itglue_flexible_asset.server_license.id
  10. notes = "This document is managed by Terraform. Changes will be overridden."
  11. }
  12. organization_id = 123457
  13. flexible_asset_type_id = 45678
  14. }
  15. resource "itglue_flexible_asset" "server_license" {
  16. traits = {
  17. license-key = "AAAA-BBBB-CCCC-DDDD"
  18. renewal-date = "2021-09-09"
  19. renewal-type = "Monthly"
  20. notes = "This document is managed by Terraform. Changes will be overridden."
  21. }
  22. organization_id = 123457
  23. flexible_asset_type_id = 45679
  24. }

Limitations

Currently password traits are not supported but all other trait types should work when passed a string, integer or boolean.

Currently tag traits can only have one ID specified.

Passwords

Passwords are recommended to be passed from something like AWS Parameter Store (refer to Example providing API key using AWS Parameter Store).

Example with an embedded password, embedded into the server flexible asset above

  1. resource "itglue_password" "server_password" {
  2. name = "test server password"
  3. username = "testusername"
  4. password = "testpassword"
  5. resource_id = itglue_flexible_asset.example_server.id
  6. resource_type = "Flexible Asset"
  7. organization_id = 123457
  8. notes = "This document is managed by Terraform. Changes will be overridden."
  9. }

Example with a standalone password

  1. resource "itglue_password" "server_password" {
  2. name = "test server password"
  3. username = "testusername"
  4. password = "testpassword"
  5. organization_id = 123457
  6. notes = "This document is managed by Terraform. Changes will be overridden."
  7. }