Skip to content

Commit

Permalink
DXE-3208 Merge pull request #63 from akamai/release/v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mgwoj authored Oct 31, 2023
2 parents 8cd9a09 + c536960 commit cf1edec
Show file tree
Hide file tree
Showing 121 changed files with 12,689 additions and 310 deletions.
32 changes: 27 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release Notes

## Version 1.10.0 (October 31, 2023)

### Features/Enhancements

* [IMPORTANT] Client Lists
* Added command `export-clientlist` which allows export of `akamai_clientlist_list` and `akamai_clientlist_activation`
resources
* Cloudlets
* Added `matches_always` field to `akamai_cloudlets_edge_redirector_match_rule` export template
* PAPI
* Added support for new rule format `v2023-09-20`

### Bug fixes

* Fixed generation of multiline text for:
* `description` variable in AppSec configuration
* `comments` and `location.comments` fields in `akamai_cloudwrapper_configuration`
* `comment` field in `akamai_dns_zone`
* `comment` field in `akamai_gtm_domain`
* `comments` field in `akamai_gtm_property`
* `description` field in `akamai_gtm_resource`
* `note` field in `akamai_property_activation` and `akamai_property_include_activation`

## Version 1.9.1 (September 26, 2023)

### Bug fixes
Expand All @@ -15,7 +38,6 @@

## Version 1.9.0 (August 29, 2023)

### Features/Enhancements

* [IMPORTANT] CloudWrapper
* Added support for `export-cloudwrapper` command which allows export of `akamai_cloudwrapper_configuration` and `akamai_cloudwrapper_activation` resources
Expand Down Expand Up @@ -59,7 +81,7 @@
* Migrated to Terraform 1.4.6 version

* PAPI
* Added support for `export-property` command with flag `--schema` for properties in frozen formats `v2023-01-05` and `v2023-05-30`.
* Added support for `export-property` command with flag `--schema` for properties in frozen formats `v2023-01-05` and `v2023-05-30`.
* Added support for import of `akamai_property_activation` resource.
* Added changes in `export-property` command:
* Added support for `STAGING` and `PRODUCTION` network configurations for `akamai_property_activation` resource.
Expand Down Expand Up @@ -146,7 +168,7 @@

* CPS
* New `export-cps` command to export DV enrollment (`akamai_cps_dv_enrollment`) or third-party enrollment with accompanying resources and data source (`akamai_cps_third_party_enrollment`,`akamai_cps_csr` and `akamai_cps_upload_certificate`)

## Version 1.1.1 (Oct 27, 2022)

### Fixes
Expand Down Expand Up @@ -326,7 +348,7 @@
* PAPI
* Remove deprecated CPCode support

## Version 0.2.0
## Version 0.2.0

### Bug Fixes

Expand All @@ -352,7 +374,7 @@ Initial release
* DNS
* Support importing existing DNS zones and related resources

* GTM
* GTM
* Support importing existing GTM domains and related resources

* PAPI
Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ for your system, or by cloning this repository and compiling it yourself.

If you want to compile it from source, you will need Go 1.18 or later:

1. Create a clone of the target repository:
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`
Expand All @@ -52,6 +52,7 @@ Built-In Commands:
export-edgeworker (alias: create-edgeworker)
export-iam (alias: create-iam)
export-imaging (alias: create-imaging)
export-clientlist (alias: create-clientlist)
list
help
Expand Down Expand Up @@ -90,7 +91,7 @@ $ akamai terraform export-domain --createconfig example.akadns.net

### Domain Notes:
1. Mapping GTM entity names to TF resource names may require normalization. Invalid TF resource name characters will be replaced by underscores, '_' in config generation.


## EdgeDNS Zones

Expand All @@ -99,13 +100,13 @@ $ akamai terraform export-domain --createconfig example.akadns.net
```
akamai terraform [global flags] export-zone [flags] <zone>
Flags:
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 import script for generated Terraform configuration script (<zone>_import.script) files. (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
--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 resource gathering and config generation. All record set types assumed. (default: false)
--recordname value Used in resources gathering or with configonly to filter recordsets. Multiple recordname flags may be specified.
Expand Down Expand Up @@ -143,15 +144,15 @@ $ akamai terraform export-zone --importscript testprimaryzone.com
#### Advanced options for --createconfig

1. namesonly - Resources for all associated Types will be generated
2. segmentconfig - Generate a modularized configuration.
2. segmentconfig - Generate a modularized configuration.
3. configonly - Generates a zone configuration without JSON itemization. The configuration generated varies based on which 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)
```
Expand All @@ -177,7 +178,7 @@ Certain export conditions require the use of a particular property rule format.
<tr>
<td>Addition of <code>--schema</code> flag</td>
<td>Your declarative property configuration and HCL-formatted rules. <strong>Does not return includes</strong> as includes are JSON-formatted.</td>
<td>≥ <code>v2023-01-05</code></td>
<td>Must be a dated rule format ≥ <code>v2023-01-05</code>. Cannot use `latest`.</td>
</tr>
<tr>
<td>Addition of <code>include</code> subcommand</td>
Expand Down Expand Up @@ -272,7 +273,7 @@ Flags:
```

### Export EdgeWorker configuration.

```
$ akamai terraform [global flags] export-edgeworker [command flags] <edgeworker_id>
```
Expand Down Expand Up @@ -336,6 +337,17 @@ Flags:
$ akamai terraform export-cps
```

## Client Lists

Export Client List.

```
akamai terraform [global flags] export-clientlist [flags] <list_id>
Flags:
--tfworkpath path Directory used to store files created when running commands. (default: current directory)
```

## General Notes

1. Terraform variable configuration is generated in a separately named TF file for each Akamai entity type. These files
Expand Down
2 changes: 1 addition & 1 deletion cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commands": [
{
"name": "terraform",
"version": "1.9.1",
"version": "1.10.0",
"description": "Administer and Manage Akamai Terraform configurations",
"bin": "https://github.com/akamai/cli-terraform/releases/download/v{{.Version}}/akamai-{{.Name}}-{{.Version}}-{{.OS}}{{.Arch}}{{.BinSuffix}}",
"auto-complete": true,
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var (
// Version holds current version of cli-terraform
Version = "1.9.1"
Version = "1.10.0"
)

// Run initializes the cli and runs it
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/akamai/cli-terraform
go 1.18

require (
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.3.0
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.4.0
github.com/akamai/cli v1.5.5
github.com/fatih/color v1.13.0
github.com/hashicorp/hcl/v2 v2.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.3.0 h1:eiPKdmGPXJCfnavOVhJ2vNDHwNilLzdXfn/CqnPmfZ4=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.3.0/go.mod h1:+8Nc6CkB/hiTEvoxxZwvY3whU5QsXxW4RhSARTMnAfI=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.4.0 h1:ElaZi3EnSfC4gTpdAYTmJCCGVGzkcmUW6IJls1NOkGU=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.4.0/go.mod h1:+8Nc6CkB/hiTEvoxxZwvY3whU5QsXxW4RhSARTMnAfI=
github.com/akamai/cli v1.5.5 h1:XKubVW8WOVP8qcgJRK2MOj8HeqC4kudvSOM0m8mJsj0=
github.com/akamai/cli v1.5.5/go.mod h1:29wClp63PEEkpDLxtqM/JrVmnwOCSaE+itIJjCAIECE=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
Expand Down
17 changes: 17 additions & 0 deletions pkg/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package commands

import (
"github.com/akamai/cli-terraform/pkg/providers/appsec"
"github.com/akamai/cli-terraform/pkg/providers/clientlists"
"github.com/akamai/cli-terraform/pkg/providers/cloudlets"
"github.com/akamai/cli-terraform/pkg/providers/cloudwrapper"
"github.com/akamai/cli-terraform/pkg/providers/cps"
Expand Down Expand Up @@ -115,6 +116,22 @@ func CommandLocator() ([]*cli.Command, error) {
BashComplete: autocomplete.Default,
})

commands = append(commands, &cli.Command{
Name: "export-clientlist",
Description: "Generates Terraform configuration for Client List resources",
Usage: "export-clientlist",
ArgsUsage: "<list_id>",
Action: validatedAction(clientlists.CmdCreateClientList, requireValidWorkpath, requireNArguments(1)),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tfworkpath",
Usage: "Directory used to store files created when running commands.",
DefaultText: "current directory",
},
},
BashComplete: autocomplete.Default,
})

commands = append(commands, &cli.Command{
Name: "export-property",
Aliases: []string{"create-property"},
Expand Down
5 changes: 2 additions & 3 deletions pkg/providers/appsec/create_appsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path/filepath"
"reflect"
"strings"
"text/template"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman"
Expand Down Expand Up @@ -120,7 +119,7 @@ func CmdCreateAppsec(c *cli.Context) error {
}

// Provide custom helper functions to get data that does not exist in the security config export
additionalFuncs := template.FuncMap{
additionalFuncs := tools.DecorateWithMultilineHandlingFunctions(map[string]any{
"exportJSON": exportJSON,
"getConfigDescription": getConfigDescription,
"getCustomRuleNameByID": getCustomRuleNameByID,
Expand All @@ -138,7 +137,7 @@ func CmdCreateAppsec(c *cli.Context) error {
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}
})

// The template processor
processor := templates.FSTemplateProcessor{
Expand Down
12 changes: 6 additions & 6 deletions pkg/providers/appsec/create_appsec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"path/filepath"
"testing"
"text/template"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman"
"github.com/akamai/cli-terraform/pkg/templates"
"github.com/akamai/cli-terraform/pkg/tools"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestProcessPolicyTemplates(t *testing.T) {
}

// Additional functions for the template processor
additionalFuncs := template.FuncMap{
additionalFuncs := tools.DecorateWithMultilineHandlingFunctions(map[string]any{
"getCustomRuleNameByID": getCustomRuleNameByID,
"getRepNameByID": getRepNameByID,
"getRuleNameByID": getRuleNameByID,
Expand All @@ -301,7 +301,7 @@ func TestProcessPolicyTemplates(t *testing.T) {
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}
})

// Template to path mappings
security := filepath.Join("modules", "security")
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestProcessPolicyTemplatesWithBotman(t *testing.T) {
// Mocked API calls
mocks := func(c *appsec.Mock, p *templates.MockProcessor) {
c.On("GetWAFMode", mock.Anything, mock.Anything).Return(&appsec.GetWAFModeResponse{Mode: "KRS"}, nil)
c.On("GetConfiguration", mock.Anything, mock.Anything).Return(&appsec.GetConfigurationResponse{Description: "A security config for demo"}, nil)
c.On("GetConfiguration", mock.Anything, mock.Anything).Return(&appsec.GetConfigurationResponse{Description: "A security config for\ndemo\n"}, nil)
}

botmanMocks := func(c *botman.Mock, p *templates.MockProcessor) {
Expand All @@ -405,7 +405,7 @@ func TestProcessPolicyTemplatesWithBotman(t *testing.T) {
}

// Additional functions for the template processor
additionalFuncs := template.FuncMap{
additionalFuncs := tools.DecorateWithMultilineHandlingFunctions(map[string]any{
"getCustomRuleNameByID": getCustomRuleNameByID,
"getRepNameByID": getRepNameByID,
"getRuleNameByID": getRuleNameByID,
Expand All @@ -423,7 +423,7 @@ func TestProcessPolicyTemplatesWithBotman(t *testing.T) {
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}
})

// Template to path mappings
security := filepath.Join("modules", "security")
Expand Down
15 changes: 15 additions & 0 deletions pkg/providers/appsec/templates/multiline.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "Text"}}
{{- if . | IsMultiline}}
{{- if . | NoNewlineAtTheEnd}}
{{- "trimsuffix(<<"}}{{. | GetEOT}}
{{. | RemoveLastNewline}}
{{. | GetEOT}}
, "\n")
{{- else}}
{{- "<<"}}{{. | GetEOT}}
{{. | RemoveLastNewline}}
{{. | GetEOT}}
{{- end}}
{{- else}}"{{. | Escape}}"
{{- end}}
{{- end}}
2 changes: 1 addition & 1 deletion pkg/providers/appsec/templates/variables.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ variable "name" {

variable "description" {
type = string
default = "{{ getConfigDescription .ConfigID }}"
default = {{template "Text" (getConfigDescription .ConfigID)}}
}

variable "hostnames" {
Expand Down
5 changes: 4 additions & 1 deletion pkg/providers/appsec/testdata/ase-botman/appsec-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ variable "name" {

variable "description" {
type = string
default = "A security config for demo"
default = <<EOT
A security config for
demo
EOT
}

variable "hostnames" {
Expand Down
Loading

0 comments on commit cf1edec

Please sign in to comment.