Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel 09052024 as3fix #977

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bigip/resource_bigip_as3.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ func resourceBigipAs3() *schema.Resource {
"tenant_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Name of Tenant. This name is used only in the case of Per-Application Deployment. If it is not provided, then a random name would be generated.",
},
"tenant_filter": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Name of Tenant",
},
"tenant_list": {
Expand Down Expand Up @@ -220,7 +222,7 @@ func resourceBigipAs3Create(ctx context.Context, d *schema.ResourceData, meta in
_ = d.Set("application_list", applicationList)
_ = d.Set("per_app_mode", true)
} else {
log.Printf("[INFO] Creating As3 config traditionally for tenants:%+v", tenantList)
log.Printf("[INFO] Creating AS3 config traditionally for tenants:%+v", tenantList)
tenantCount := strings.Split(tenantList, ",")
if tenantFilter != "" {
log.Printf("[DEBUG] tenantFilter:%+v", tenantFilter)
Expand Down Expand Up @@ -286,12 +288,13 @@ func resourceBigipAs3Create(ctx context.Context, d *schema.ResourceData, meta in
}
func resourceBigipAs3Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*bigip.BigIP)
log.Printf("[INFO] Reading As3 config")
log.Printf("[INFO] Reading AS3 config")
var name string
var tList string
as3Json := d.Get("as3_json").(string)
perappMode := d.Get("per_app_mode").(bool)
log.Printf("[INFO] AS3 config:%+v", as3Json)
if d.Get("as3_json") != nil {
if d.Get("as3_json") != nil && !perappMode {
tList, _, _ = client.GetTenantList(as3Json)
if createdTenants != "" && createdTenants != tList {
tList = createdTenants
Expand Down
90 changes: 85 additions & 5 deletions docs/resources/bigip_as3.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ description: |-

`bigip_as3` provides details about bigip as3 resource

This resource is helpful to configure as3 declarative JSON on BIG-IP.
This resource is helpful to configure AS3 declarative JSON on BIG-IP.

~> This Resource also supports **Per-Application** mode of AS3 deployment, more information on **Per-Application** mode can be found [Per-App](https://clouddocs.f5.com/products/extensions/f5-appsvcs-extension/latest/userguide/per-app-declarations.html)

-> For Supporting AS3 Per-App mode of deployment, AS3 version on BIG-IP should be > **v3.50**

~> For Deploying AS3 JSON in Per-App mode, this resource provided with a attribute [tenant_name](#tenant_name) to be passed to add application on specified tenant, else random tenant name will be generated.


## Example Usage

```hcl


# Example Usage for json file
resource "bigip_as3" "as3-example1" {
as3_json = file("example1.json")
Expand All @@ -27,17 +33,40 @@ resource "bigip_as3" "as3-example1" {
as3_json = file("example2.json")
tenant_filter = "Sample_03"
}
```

## Example Usage for Per-App mode deployment

[perApplication as3](#perApplication_example)

```hcl

# Per-Application Deployment - Example Usage for json file with tenant name
resource "bigip_as3" "as3-example1" {
as3_json = file("perApplication_example.json")
tenant_name = "Test"
}

# Per-Application Deployment - Example Usage for json file without tenant name - Random tenant name is generated in this case
resource "bigip_as3" "as3-example1" {
as3_json = file("perApplication_example.json")
}
```

## Argument Reference


* `as3_json` - (Required) Path/Filename of Declarative AS3 JSON which is a json file used with builtin ```file``` function

* `tenant_filter` - (Optional) If there are multiple tenants on a BIG-IP, this attribute helps the user to set a particular tenant to which he want to reflect the changes. Other tenants will neither be created nor be modified.

* `tenant_name` - (Optional) Name of Tenant. This name is used only in the case of Per-Application Deployment. If it is not provided, then a random name would be generated.

* `per_app_mode` - (Computed) - Will specify whether is deployment is done via Per-Application Way or Traditional Way

* `tenant_list` - (Optional) - List of tenants currently deployed on the Big-Ip

* `application_list` - (Optional) - List of applications currently deployed on the Big-Ip

* `ignore_metadata` - (Optional) Set True if you want to ignore metadata changes during update. By default it is set to false

* `as3_example1.json` - Example AS3 Declarative JSON file with single tenant
Expand Down Expand Up @@ -167,6 +196,58 @@ resource "bigip_as3" "as3-example1" {

```

* `perApplication_example` - Per Application Example - JSON file with multiple Applications (and no Tenant Details)

```json
{
"schemaVersion": "3.50.1",
"Application1": {
"class": "Application",
"service": {
"class": "Service_HTTP",
"virtualAddresses": [
"192.1.1.1"
],
"pool": "pool"
},
"pool": {
"class": "Pool",
"members": [
{
"servicePort": 80,
"serverAddresses": [
"192.0.1.10",
"192.0.1.20"
]
}
]
}
},
"Application2": {
"class": "Application",
"service": {
"class": "Service_HTTP",
"virtualAddresses": [
"192.1.2.1"
],
"pool": "pool"
},
"pool": {
"class": "Pool",
"members": [
{
"servicePort": 80,
"serverAddresses": [
"192.0.2.10",
"192.0.2.20"
]
}
]
}
}
}
```

## Import

As3 resources can be imported using the partition name, e.g., ( use comma separated partition names if there are multiple partitions in as3 deployments )
Expand Down Expand Up @@ -364,5 +445,4 @@ resource "bigip_as3" "test" {

```

* `AS3 documentation` - https://clouddocs.f5.com/products/extensions/f5-appsvcs-extension/latest/userguide/composing-a-declaration.html

* `AS3 documentation` - https://clouddocs.f5.com/products/extensions/f5-appsvcs-extension/latest/userguide/composing-a-declaration.html
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/Azure/azure-storage-blob-go v0.13.0
github.com/Azure/go-autorest/autorest v0.11.18
github.com/Azure/go-autorest/autorest/adal v0.9.13
github.com/f5devcentral/go-bigip v0.0.0-20240509075551-d135b50ad60c
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509075551-d135b50ad60c
github.com/f5devcentral/go-bigip v0.0.0-20240509154308-41ddfd3c8299
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509154308-41ddfd3c8299
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/f5devcentral/go-bigip v0.0.0-20240509075551-d135b50ad60c h1:EA9qSu00QzCKcilTj9UqKTMXIwKeLtPceoQzAudLHa8=
github.com/f5devcentral/go-bigip v0.0.0-20240509075551-d135b50ad60c/go.mod h1:0Lkr0fBU6O1yBxF2mt9JFwXpaFbIb/wAY7oM3dMJDdA=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509075551-d135b50ad60c h1:SlUYdX9vu+sVOx3EaxNIi4mmPJ+60NtxV8Iu/Rd1dXg=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509075551-d135b50ad60c/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
github.com/f5devcentral/go-bigip v0.0.0-20240509154308-41ddfd3c8299 h1:rPDOzyyOGTqD9OlD87vytlfuOYGpDfmXhtblJfPHU+E=
github.com/f5devcentral/go-bigip v0.0.0-20240509154308-41ddfd3c8299/go.mod h1:0Lkr0fBU6O1yBxF2mt9JFwXpaFbIb/wAY7oM3dMJDdA=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509154308-41ddfd3c8299 h1:iVOwgYmftWB4P+rcc8hVM9W2Q+sdRdRw9L4xehE9heo=
github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509154308-41ddfd3c8299/go.mod h1:r7o5I22EvO+fps2u10bz4ZUlTlNHopQSWzVcW19hK3U=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
Expand Down
24 changes: 19 additions & 5 deletions vendor/github.com/f5devcentral/go-bigip/as3bigip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 19 additions & 17 deletions vendor/github.com/f5devcentral/go-bigip/bigip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ github.com/apparentlymart/go-textseg/v13/textseg
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
# github.com/f5devcentral/go-bigip v0.0.0-20240509075551-d135b50ad60c
# github.com/f5devcentral/go-bigip v0.0.0-20240509154308-41ddfd3c8299
## explicit; go 1.20
github.com/f5devcentral/go-bigip
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509075551-d135b50ad60c
# github.com/f5devcentral/go-bigip/f5teem v0.0.0-20240509154308-41ddfd3c8299
## explicit; go 1.13
github.com/f5devcentral/go-bigip/f5teem
# github.com/fatih/color v1.13.0
Expand Down
Loading