cli-terraform

command module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

Akamai CLI for Akamai Terraform Provider

Build Status Go Report Card GitHub release License GoDoc

Get started

Create authentication credentials

Before you can use this CLI, you need to Create authentication credentials.

Install

To install this package, use Akamai CLI:

$ akamai install terraform

You may also use this as a stand-alone command by downloading the latest release binary for your system, or by cloning this repository and compiling it yourself.

Compile from source

If you want to compile it from the source, you need Go 1.22 or later:

  1. Create a clone of the target repository: git clone https://github.com/akamai/cli-terraform.git
  2. Change to the package directory and compile the binary:
    • Linux/macOS/*nix: go build -o akamai-terraform
    • Windows: go build -o akamai-terraform.exe

General usage

Usage:
  akamai terraform [global flags] command [command flags] [arguments...]

Description:
  Export selected resources for faster adoption in Terraform.

Commands:
  export-domain
  export-zone
  export-appsec
  export-clientlist
  export-property
  export-property-include
  export-cloudwrapper
  export-cloudlets-policy
  export-edgekv
  export-edgeworker
  export-iam
  export-imaging
  export-cps
  export-cloudaccess
  list
  help

Global Flags:
  --edgerc value, -e value                 Location of the credentials file (default: "/home/user/.edgerc") [$AKAMAI_EDGERC]
  --section value, -s value                Section of the credentials file (default: "default") [$AKAMAI_EDGERC_SECTION]
  --accountkey value, --account-key value  Account switch key [$AKAMAI_EDGERC_ACCOUNT_KEY]
  --help                                   show help (default: false)
  --version                                Output CLI version (default: false)

GTM Domains

Usage
   akamai terraform [global flags] export-domain [flags] <domain>

Flags:
   --tfworkpath path       Directory used to store files created when running commands. (default: current directory)
Export Terraform GTM domain configuration
$ akamai terraform export-domain example.akadns.net
Domain notes

Mapping GTM entity names to TF resource names may require normalization. Invalid TF resource name characters are replaced by underscores, '_' in config generation.

Edge DNS Zones

Usage
   akamai terraform [global flags] export-zone [flags] <zone>

Flags:
   --tfworkpath path       Directory used to store files created when running commands. (default: current directory)
   --resources             Creates a JSON-formatted resource file for import: `<zone>_resources.json`. The `--createconfig` flag uses this file as an input. (default: false)
   --createconfig          Creates these Terraform configuration files based on the values in `<zone>_resources.json`: `<zone>.tf` and `dnsvars.tf`. (default: false)
   --importscript          Creates an import script for the generated Terraform configuration script files (<zone>_import.script). (default: false)
   --segmentconfig         Use with the `--createconfig` flag to group and segment records by name into separate config files. (default: false)
   --configonly            Directive for createconfig. Create entire Terraform zone and recordsets configuration (<zone>.tf), dnsvars.tf. Saves zone config for
                           importscript. Ignores any existing resource JSON file. (default: false)
   --namesonly             Directive for both gathering resources and generating a config file. All record set types are assumed. (default: false)
   --recordname value      Used when gathering resources or with the `--configonly` to filter recordsets. You can specify the `--recordname` flag multiple times.
Export list of zone record sets

The command creates a <zone>_resources.json file.

$ akamai terraform export-zone --resources testprimaryzone.com
Generate Terraform zone configuration file

Default arguments create these files: <zone>.tf, <zone>_zoneconfig.json, and dnsvars.tf.

$ akamai terraform export-zone --createconfig testprimaryzone.com
Generate zone import script

The command creates a <zone>_resource_import.script file.

$ akamai terraform export-zone --importscript testprimaryzone.com
Zone notes
  1. The resources directive generates a <zone>_resources.json file for consumption by createconfig.
  2. The createconfig directive generates a <zone>_zoneconfig.json file for consumption by importscript.
Advanced options for --resources
  1. recordname. Filters the generated resources list by a record name or record names.
  2. namesonly. Generates a resource file with record set names only. All associated Types are represented.
Advanced options for --createconfig
  1. namesonly. Generates resources for all associated Types.
  2. segmentconfig. Generates a modularized configuration.
  3. configonly. Generates a zone configuration without the JSON itemization. The configuration generated varies based on the set of flags you use.

AppSec

Usage
   akamai terraform [global flags] export-appsec [flags] <name_of_security_config>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)

Property Manager Properties

Certain export conditions require the use of a particular property rule format. Verify whether your rule format matches the use case requirement and update your rule format as needed.

Export condition Output Rule format
General Your declarative property configuration and its JSON-formatted rules. Any supported format.
Addition of the --rules-as-hcl flag Your declarative property configuration and HCL-formatted rules. Does not return includes as includes are JSON-formatted. Must be a dated rule format ≥ v2023-01-05. Cannot use latest.
Addition of the --split-depth=X flag Rules will be exported into a module. Each rule up to an X nesting level will be placed in dedicated file. For example, --split-depth=1 means that the default/root rule and all its direct children will be placed in dedicated files. Rules with higher nesting levels will be placed in a file of their closest ancestor. Any supported format.
Usage
   akamai terraform [global flags] export-property [flags] <property name>

Flags:
   --tfworkpath path             Directory used to store files created when running commands. (default: current directory)
   --version value               Property version to import  (default: LATEST)
   --rules-as-hcl                Exports rules as the `akamai_property_rules_builder` data source in HCL format.
   --akamai-property-bootstrap   Exports the referenced property using a combination of `akamai-property-bootstrap` and `akamai-property` resources. (default: false)
   --split-depth value           Exports the rules into a dedicated module. Each rule will be placed in a separate file up to a specified nesting level.

You can use the split-depth flag only along with the rules-as-hcl flag.

Export property manager property configuration
$ akamai terraform export-property

Property Manager Includes

Certain export conditions require the use of a particular property rule format. Verify your rule format matches the use case requirement and update your rule format as needed.

Export condition Output Rule format
General Your declarative include configuration and its JSON-formatted rules. Any supported format.
Addition of the --rules-as-hcl flag Your declarative include configuration and HCL-formatted rules. Does not return includes as includes are JSON-formatted. Must be a dated rule format ≥ v2023-01-05. Cannot use latest.
Addition of the --split-depth=X flag Rules will be exported into a module. Each rule will be placed in a dedicated file up to a specified nesting level. For example, --split-depth=1 means that the default/root rule and all its direct children will be placed in dedicated files. Rules with higher nesting levels will be placed in a file of their closest ancestor. Any supported format.
Usage
   akamai terraform [global flags] export-property-include [flags] <contract_id> <include_name>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
   --rules-as-hcl         Exports rules as the `akamai_property_rules_builder` data source in HCL format.
   --split-depth value    Exports the rules into a dedicated module. Each rule will be placed in a separate file up to a specified nesting level.

You can use the split-depth flag only along with the rules-as-hcl flag.

Export property manager include configuration
$ akamai terraform export-property-include

Cloudlets

Usage
   akamai terraform [global flags] export-cloudlets-policy [flags] <policy_name>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
Export Cloudlets policy configuration
$ akamai terraform export-cloudlets-policy

CloudWrapper

Usage
   akamai terraform [global flags] export-cloudwrapper [flags] <configuration_id>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
Export CloudWrapper configuration
$ akamai terraform export-cloudwrapper

EdgeWorkers

EdgeKV usage
   akamai terraform [global flags] export-edgekv [flags] <namespace_name> <network>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
Export EdgeKV configuration
$ akamai terraform [global flags] export-edgekv [flags] <namespace_name> <network>
EdgeWorker usage
   akamai terraform [global flags] export-edgeworker [flags] <edgeworker_id>

Flags:
   --bundlepath path      Path location of the EdgeWorkers `tgz` code bundle. Its default value is the same as for the `--tfworkpath` flag.
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
Export EdgeWorker configuration
$ akamai terraform [global flags] export-edgeworker [flags] <edgeworker_id>

Identity and Access Management

Usage
   akamai terraform [global flags] export-iam [subcommand] [flags]

Subcommands:
    all                     Exports all available Terraform users, groups, roles, IP allowlist and CIDR block resources.
    allowlist               Exports Terraform IP Allowlist and CIDR block resources
    group [group id]        Exports group by id with relevant users and their roles
    role [role id]          Exports role by id with relevant users and their groups
    user [user's email]     Exports user by email with relevant user's groups and roles

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)
   --only                 Exports only the specified Identity and Access Management resource, excluding additional details when present. (Can only be used with `group`, `role`, or `user` subcommands.)
Export Identity and Access Management configuration
$ akamai terraform export-iam

Image and Video Manager

Usage
   akamai terraform [global flags] export-imaging [flags] <contract_id> <policy_set_id>

Flags:
   --tfworkpath path         Directory used to store files created when running commands. (default: current directory)
   --policy-json-dir path    Path location for a policy in JSON format. Its default value is the same as for the `--tfworkpath` flag.
   --policy-as-hcl           Generates content of the policy using HCL format instead of JSON. (default: false)
Export Image and Video policy configuration
$ akamai terraform export-imaging

Certificate Provisioning System (CPS)

Usage
   akamai terraform [global flags] export-cps [flags] <enrollment_id> <contract_id>

Flags:
   --tfworkpath path                        Directory used to store files created when running commands. (default: current directory)
Export CPS configuration
$ akamai terraform export-cps

Client Lists

Usage
akamai terraform [global flags] export-clientlist [flags] <list_id>

Flags:
   --tfworkpath path      Directory used to store files created when running commands. (default: current directory)

Cloud Access Manager

Usage
   akamai terraform [global flags] export-cloudaccess [flags] <cloud_access_key_uid>

Flags:
   --tfworkpath path         Directory used to store files created when running commands. (default: current directory)
   --group_id                The unique identifier for the group (without the `grp_` prefix) assigned to the access key.
   --contract_id             The unique identifier for the contract (without the `ctr_` prefix) assigned to the access key.

General notes

Terraform variable configuration is generated in a separately named TF file for each Akamai entity type. These files will need to be merged by the Admin in the case where multiple entities are managed concurrently with the Terraform client.

License

Copyright 2024 Akamai Technologies, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Overview

Package main contains entry code for the application.

Directories

Path Synopsis
Package cli contains code for managing the command line interface functionality.
Package cli contains code for managing the command line interface functionality.
pkg
commands
Package commands contains code defining the export commands.
Package commands contains code defining the export commands.
edgegrid
Package edgegrid contains code for manipulating edgegrid access settings
Package edgegrid contains code for manipulating edgegrid access settings
providers/appsec
Package appsec contains code for exporting application security configuration
Package appsec contains code for exporting application security configuration
providers/clientlists
Package clientlists contains code for exporting Client Lists
Package clientlists contains code for exporting Client Lists
providers/cloudaccess
Package cloudaccess contains code for exporting CloudAccess key
Package cloudaccess contains code for exporting CloudAccess key
providers/cloudlets
Package cloudlets contains code for exporting cloudlets configuration
Package cloudlets contains code for exporting cloudlets configuration
providers/cloudwrapper
Package cloudwrapper contains code for exporting CloudWrapper configuration
Package cloudwrapper contains code for exporting CloudWrapper configuration
providers/cps
Package cps contains code for exporting Certificate Provisioning System (CPS) configuration
Package cps contains code for exporting Certificate Provisioning System (CPS) configuration
providers/dns
Package dns contains code for exporting the DNS configuration.
Package dns contains code for exporting the DNS configuration.
providers/edgeworkers
Package edgeworkers contains code for exporting edge workers and edge kv configuration
Package edgeworkers contains code for exporting edge workers and edge kv configuration
providers/gtm
Package gtm contains code for exporting the global traffic manager configuration.
Package gtm contains code for exporting the global traffic manager configuration.
providers/iam
Package iam contains code for exporting identity access manager configuration
Package iam contains code for exporting identity access manager configuration
providers/imaging
Package imaging contains code for exporting policies for images and videos
Package imaging contains code for exporting policies for images and videos
providers/papi
Package papi contains code for exporting properties.
Package papi contains code for exporting properties.
templates
Package templates allows processing multiple templates which use common data
Package templates allows processing multiple templates which use common data
tools
Package tools contains various functions to help with processing of the templates
Package tools contains various functions to help with processing of the templates

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳