Skip to content

Commit

Permalink
adding as3 per app fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RavinderReddyF5 committed May 9, 2024
1 parent eda4997 commit 803de91
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 30 deletions.
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
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.

0 comments on commit 803de91

Please sign in to comment.