Skip to content

Commit 41698e8

Browse files
authored
feat: Added support for Deploy and Run use case (#44)
* feat: added logic to manage subscriptionID * fix: added sensitive flag to subscriptionId parameter * feat: added subscription_id support into DA input * fix: fixed cra scan with subid crn * fix: disabled nullable for subid crn in both tests SKIP UPGRADE TEST * fix: fixed subscriptionIDs in tests * feat: implemented DR use-case * docs: fixed readme * feat: added support for DR use-case and modified existing examples * feat: readded trial plan only for tests * feat: renamed Trial plan to programmatic name free for testing * docs: some renaming and fixes on docs * docs: added link to main doc * docs: updated doc
1 parent 934db89 commit 41698e8

22 files changed

+585
-112
lines changed

README.md

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- Update this title with a descriptive name. Use sentence case. -->
2-
# Enterprise Application Service for Java (also know as EASeJava)
2+
# Enterprise Application Service for Java
33

44
<!--
55
Update status and "latest release" badges:
@@ -20,7 +20,9 @@ For information, see "Module names and descriptions" at
2020
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
2121
-->
2222

23-
Use this module to provision and configure an [Enterprise Application Service](https://cloud.ibm.com/catalog/services/enterprise-application-service) instance on IBM Cloud.
23+
Use this module to provision and configure an [Enterprise Application Service](https://cloud.ibm.com/catalog/services/enterprise-application-service) (also shorthened to EASeJava or simply to `ease`) instance on IBM Cloud.
24+
25+
For more information about the Enterprice Application Service product you can refer to the [product documentation](https://www.ibm.com/docs/en/ease?topic=overview)
2426

2527

2628
<!-- The following content is automatically populated by the pre-commit hook -->
@@ -29,7 +31,8 @@ Use this module to provision and configure an [Enterprise Application Service](h
2931
* [terraform-ibm-enterprise-app-java](#terraform-ibm-enterprise-app-java)
3032
* [Examples](./examples)
3133
* [Basic example](./examples/basic)
32-
* [Complete example](./examples/complete)
34+
* [Build, deploy and run complete example](./examples/bdr_complete)
35+
* [Deploy and run complete example](./examples/dr_complete)
3336
* [Contributing](#contributing)
3437
<!-- END OVERVIEW HOOK -->
3538

@@ -42,24 +45,49 @@ https://terraform-ibm-modules.github.io/documentation/#/implementation-guideline
4245
-->
4346
<!-- ## Reference architectures -->
4447

45-
## Prerequisites
48+
## Enterprise Application Service use cases support
49+
50+
This module supports both the use cases provided by the Enterprise Application Service:
51+
- **Deploy and Run your application** use case: you can provide your existing prebuilt enterprise archive (EAR) or web archive (WAR) file in a Maven artifact repository, the service will allow to deploy and to run it.
52+
- **Build, deploy and run your application** use case: you can provide your application source code through its GitHub repository URL, the service will allow to build, deploy and then run it.
53+
54+
For more details about the two different use-cases and the input parameters to use please refer to the sections below.
55+
56+
### Mandatory input parameters for both the use cases
4657

47-
This module has the following prerequisites as mandatory input parameters:
58+
Both the use-cases supported by this module need you to specify the following parameters as mandatory inputs.
4859

4960
1. The IBM Cloud API Key (https://cloud.ibm.com/iam/apikeys) for the account where to deploy the Enterprise Application Service instance
5061
1. Resource Group ID (https://cloud.ibm.com/account/resource-groups) containing the Enterprise Application Service instance
5162

52-
Optionally, the following optional input parameters are required in order to pre-configure the Enterprise Application Service instance:
63+
## Deploy and Run use case input parameters
64+
65+
The following optional input parameters are required in order to pre-configure the Enterprise Application Service instance for the Deploy and Run use case:
66+
67+
1. URL of the Maven artifact repository storing the existing prebuilt enterprise archive (EAR) or web archive (WAR) file to run in the Enterprise Application Service instance
68+
1. If your Maven artifact repository needs basic authentication, you can specify the username and password using the related input variables. If the repository doesn't need authentication, you can leave them to their default values.
69+
2. URL of the GitHub repository storing the application deployment configuration to run in the Enterprise Application Service instance
70+
3. GitHub token with read access to the configuration repository.
71+
72+
**Note:** all these parameters (excluding the Maven repository username and password) are mandatory in the case any of them is different than their default null value (the GitHub token is mandatory also if the configuration repository is public). When all of them are left to the default null value it will be possible to configure the instance with their values once the instance is successfully created, as describe [here](#create-an-enterprise-application-service-instance-without-setting-any-repository)
73+
74+
The GitHub configuration repository must satisfy a further prerequisite as described [here](#ibm-appflow-github-application-prerequisite)
5375

54-
1. URL of the repository storing the Java liberty application source code to build in the Enterprise Application Service instance
55-
1. URL of the repository storing the Java liberty application configuration to build in the Enterprise Application Service instance
56-
1. GitHub token with read access to the source code and to the configuration repositories.
76+
For more details about this use-case please refer to the Enterprise Application Service product documentation section available [here](https://www.ibm.com/docs/en/ease?topic=deploy-run-your-application-option)
5777

58-
**Note:** all these parameters are mandatory in the case any of them is different than their default null value, with the GitHub token mandatory also if the source code and the configuration repositories are both public.
78+
### Build, Deploy and Run use case input parameters
5979

60-
In the case the source code and the configuration repositories are not set at Enterprise Application Service instance deployment time, it will be possible to configure them through the Enterprise Application Service dashboard url that will be included in the `ease_instance` output details of this module.
80+
The following optional input parameters are required in order to pre-configure the Enterprise Application Service instance for the Build, deploy and run use case:
6181

62-
In both the cases (pre-configure the Enterprise Application Service instance at deployment time or configure it through its dashboard when the instance deployment is complete), the repositories must satisfy a further prerequisite as described [here](#ibm-appflow-github-application-prerequisite)
82+
1. URL of the GitHub repository storing your application source code to Build, deploy and run in the Enterprise Application Service instance
83+
1. URL of the GitHub repository storing your application configuration to Build, deploy and run in the Enterprise Application Service instance
84+
1. GitHub token with read access the source code and configuration repositories.
85+
86+
**Note:** all these parameters are mandatory in the case any of them is different than their default null value (the GitHub token is mandatory also if both the repositories are public). When all of them are left to the default null value it will be possible to configure the instance with their values once the instance is successfully created, as describe [here](#create-an-enterprise-application-service-instance-without-setting-any-repository)
87+
88+
Both the repositories must satisfy a further prerequisite as described [here](#ibm-appflow-github-application-prerequisite)
89+
90+
For more details about this use-case please refer to the Enterprise Application Service product documentation section available [here](https://www.ibm.com/docs/en/ease?topic=build-deploy-run-your-application-option)
6391

6492
#### IBM AppFlow GitHub application prerequisite
6593

@@ -69,8 +97,13 @@ To install and configure the **IBM AppFlow** GitHub application refer to https:/
6997

7098
**Note:** in the case you need to configure an Enterprise Application Service instance in an environment different from IBM Cloud public platform, you need to install and configure a specific version of the **IBM AppFlow** GitHub application.
7199

100+
### Create an Enterprise Application Service instance without setting any repository
101+
102+
This module also supports to create an instance of the Enterprise Application Service without setting any source (GitHub or Maven) and configuration repository: in this case it will be possible to configure them through the Enterprise Application Service dashboard accessible through the dashboard URL returned in the `ease_instance` output details of this module.
103+
72104
### Java liberty sample application
73-
For an example of source code and configuration repositories to build in an Enterprise Application Service instance you can fork the repositories below:
105+
106+
For an example of source code and configuration repositories to Build, deploy and run in an Enterprise Application Service instance you can fork the repositories below:
74107

75108
- source code repository: https://github.com/IBMAppFlowTest/sample-getting-started
76109

@@ -107,8 +140,6 @@ module "ease_module" {
107140
}
108141
```
109142

110-
111-
112143
### Required IAM access policies
113144

114145
<!-- PERMISSIONS REQUIRED TO RUN MODULE
@@ -157,13 +188,16 @@ No modules.
157188

158189
| Name | Description | Type | Default | Required |
159190
|------|-------------|------|---------|:--------:|
160-
| <a name="input_config_repo"></a> [config\_repo](#input\_config\_repo) | The URL for the repository storing the configuration to use for the application to deploy through IBM Cloud Enterprise Application Service. | `string` | `null` | no |
191+
| <a name="input_config_repo"></a> [config\_repo](#input\_config\_repo) | The URL for the repository storing the configuration to use for the application to run through Enterprise Application Service on IBM Cloud. | `string` | `null` | no |
161192
| <a name="input_ease_name"></a> [ease\_name](#input\_ease\_name) | The name for the newly provisioned Enterprise Application Service instance. | `string` | n/a | yes |
193+
| <a name="input_maven_repository_password"></a> [maven\_repository\_password](#input\_maven\_repository\_password) | Maven repository authentication password if needed. Default to null. | `string` | `null` | no |
194+
| <a name="input_maven_repository_username"></a> [maven\_repository\_username](#input\_maven\_repository\_username) | Maven repository authentication username if needed. Default to null. | `string` | `null` | no |
162195
| <a name="input_plan"></a> [plan](#input\_plan) | The desired pricing plan for Enterprise Application Service instance. | `string` | `"standard"` | no |
163196
| <a name="input_region"></a> [region](#input\_region) | The desired region for deploying Enterprise Application Service instance. | `string` | `"us-east"` | no |
164-
| <a name="input_repos_git_token"></a> [repos\_git\_token](#input\_repos\_git\_token) | The GitHub token to read from the application and configuration repos. It cannot be null if var.source\_repo and var.config\_repo are not null. | `string` | `null` | no |
197+
| <a name="input_repos_git_token"></a> [repos\_git\_token](#input\_repos\_git\_token) | The GitHub token to read from the application and configuration repositories. It cannot be null if var.source\_repo and var.config\_repo are not null. | `string` | `null` | no |
165198
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The ID of the resource group to use for the creation of the Enterprise Application Service instance. | `string` | n/a | yes |
166-
| <a name="input_source_repo"></a> [source\_repo](#input\_source\_repo) | The URL for the repository storing the source code of the application to deploy through IBM Cloud Enterprise Application Service. | `string` | `null` | no |
199+
| <a name="input_source_repo"></a> [source\_repo](#input\_source\_repo) | The URL for the repository storing the source code of the application or the URL of the Maven artifact repository storing the existing prebuilt archive (WAR or EAR) to deploy and run through Enterprise Application Service on IBM Cloud. | `string` | `null` | no |
200+
| <a name="input_source_repo_type"></a> [source\_repo\_type](#input\_source\_repo\_type) | Type of the source code repository. For maven source repository type, use value `maven`. Git for GitHub repository. Default value set to git. | `string` | `"git"` | no |
167201
| <a name="input_subscription_id"></a> [subscription\_id](#input\_subscription\_id) | ID of the subscription to use to create the Enterprise Application Service instance. | `string` | n/a | yes |
168202
| <a name="input_tags"></a> [tags](#input\_tags) | Metadata labels describing the service instance, i.e. test | `list(string)` | `[]` | no |
169203

examples/bdr_complete/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Build, deploy and run complete example
2+
3+
A Build, deploy and run use-case example to show how to provision an Enterprise Application Service instance by passing application source and configuration repositories as input.
4+
In addiction to the two repositories, the example shows how to include the GitHub token with the right permissions to access the repositories: in the example the token is pulled from an IBM Cloud secrets manager instance where it is stored, by passing the secret CRN which is used to extract the Secrets Manager instance, its region and the secretID to pull the secret value
5+
Note that the three parameters (repositories and token) are mandatory if any of them is not null.
6+
7+
The following resources are provisioned by this example:
8+
- A new resource group, if an existing one is not passed in.
9+
- A new Enterprise Application Service instance in the given resource group on an IBM Cloud account.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/complete/variables.tf renamed to examples/bdr_complete/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "resource_tags" {
1717
variable "prefix" {
1818
type = string
1919
description = "Prefix to append to all resources created by this example"
20-
default = "ease-complete"
20+
default = "bdr-complete"
2121
}
2222

2323
variable "resource_group" {
File renamed without changes.

examples/complete/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/dr_complete/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Deploy and run complete example
2+
3+
A Deploy and run use-case example to show how to provision an Enterprise Application Service instance by passing an already built maven application through its maven repository URL as source repository and the application configuration through the config repository as input parameters.
4+
The example sets also the var.source_repo_type input variable to "maven" and the "username" and "password" values to a set of fake values for testing purposes
5+
In addiction to the configuration repository, the example shows how to
6+
- include the GitHub token with the right permissions to access it: in the example the token is pulled from an IBM Cloud secrets manager instance where it is stored, by passing the secret CRN which is used to extract the Secrets Manager instance, its region and the secretID to pull the secret value.
7+
- include the maven repository credentials (username and password)
8+
Note that the three parameters, maven and configuration repositories and the github token, are mandatory if any of them is not null.
9+
10+
The following resources are provisioned by this example:
11+
- A new resource group, if an existing one is not passed in.
12+
- A new Enterprise Application Service instance in the given resource group on an IBM Cloud account.

examples/dr_complete/main.tf

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
locals {
2+
sleep_create = "30s"
3+
}
4+
5+
########################################################################################################################
6+
# Resource group management
7+
########################################################################################################################
8+
9+
module "resource_group" {
10+
source = "terraform-ibm-modules/resource-group/ibm"
11+
version = "1.1.6"
12+
# if an existing resource group is not set (null) create a new one using prefix
13+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
14+
existing_resource_group_name = var.resource_group
15+
}
16+
17+
########################################################################################################################
18+
# Reading the GitHub token from the existing Secrets Manager instance
19+
########################################################################################################################
20+
21+
# parsing secret crn to collect the secrets manager ID, the region and the secret ID
22+
module "crn_parser_token" {
23+
count = var.repos_git_token_secret_crn != null ? 1 : 0
24+
source = "terraform-ibm-modules/common-utilities/ibm//modules/crn-parser"
25+
version = "1.1.0"
26+
crn = var.repos_git_token_secret_crn
27+
}
28+
29+
data "ibm_sm_arbitrary_secret" "sm_repo_github_token" {
30+
count = var.repos_git_token_secret_crn != null ? 1 : 0
31+
instance_id = module.crn_parser_token[0].service_instance
32+
#checkov:skip=CKV_SECRET_6: does not require high entropy string as is static type
33+
region = module.crn_parser_token[0].region
34+
secret_id = module.crn_parser_token[0].resource
35+
provider = ibm.ibm-sm
36+
}
37+
38+
locals {
39+
repos_git_token = var.repos_git_token_secret_crn != null ? data.ibm_sm_arbitrary_secret.sm_repo_github_token[0].payload : null
40+
}
41+
42+
########################################################################################################################
43+
# Reading the subscriptionID value from the existing Secrets Manager instance
44+
########################################################################################################################
45+
46+
# parsing secret crn to collect the secrets manager ID, the region and the secret ID
47+
module "crn_parser_subid" {
48+
source = "terraform-ibm-modules/common-utilities/ibm//modules/crn-parser"
49+
version = "1.1.0"
50+
crn = var.subscription_id_secret_crn
51+
}
52+
53+
data "ibm_sm_arbitrary_secret" "sm_subscription_id" {
54+
instance_id = module.crn_parser_subid.service_instance
55+
#checkov:skip=CKV_SECRET_6: does not require high entropy string as is static type
56+
region = module.crn_parser_subid.region
57+
secret_id = module.crn_parser_subid.resource
58+
provider = ibm.ibm-sm
59+
}
60+
61+
########################################################################################################################
62+
# Enterprise Application Service Instance deployment
63+
########################################################################################################################
64+
65+
module "ease" {
66+
source = "../../"
67+
ease_name = "${var.prefix}-app"
68+
resource_group_id = module.resource_group.resource_group_id
69+
tags = var.resource_tags
70+
plan = var.plan
71+
region = var.region
72+
config_repo = var.config_repo
73+
source_repo = var.source_repo
74+
repos_git_token = local.repos_git_token
75+
subscription_id = data.ibm_sm_arbitrary_secret.sm_subscription_id.payload
76+
# deploy and run use-case specific inputs
77+
source_repo_type = "maven"
78+
maven_repository_username = var.maven_repository_username
79+
maven_repository_password = var.maven_repository_password
80+
}
81+
82+
locals {
83+
# collecting the dashboard_url from the resource creation output as it is not returned when reading using the datasource
84+
app_dashboard_url = module.ease.ease_instance.dashboard_url
85+
}
86+
87+
# as the EASeJava app deployment expects some asynch tasks to be performed we wait for a configured interval before loading the resource instance details
88+
resource "time_sleep" "wait_deployment" {
89+
depends_on = [module.ease]
90+
create_duration = local.sleep_create
91+
}
92+
93+
data "ibm_resource_instance" "ease_resource" {
94+
depends_on = [time_sleep.wait_deployment]
95+
identifier = module.ease.ease_instance.id
96+
}

0 commit comments

Comments
 (0)