Skip to content

Commit

Permalink
Merge pull request #7 from Nadine2016/patch-1
Browse files Browse the repository at this point in the history
readme updates
  • Loading branch information
SaiKrishnaMohan7 authored Sep 20, 2019
2 parents be7d171 + a150d45 commit 4bef8c1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 74 deletions.
98 changes: 44 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
# VSI-database template
# VSI-database

This sample template configures an IBM Cloud database instance and virtual server instance. Security groups are configured so that the virtual server instance can access the IBM Cloud database instance on the IBM Cloud database instance connection port, which is dynamically defined. Whitelisting is configured on the IBM Cloud database instance to allow access only from the VSI IP address.
Use this template to provision a classic virtual server instance (VSI) in IBM Cloud that is set up with an IBM Cloud Databases for PostgreSQL instance by using Terraform or IBM Cloud Schematics. The IBM Cloud database service is automatically configured during the installation and security groups are created so that your virtual server instance can connect to the database port. To ensure that your database instance can be accessed by the virtual server instance only, whitelist rules are added to your database instance.

To apply the VSI-database template in IBM Cloud with IBM Cloud Schematics, you must select the template from the [IBM Cloud catalog](cloud.ibm.com/catalog/content/LAMP), enter the configuration for your classic virtual server instance and database service, and install the template. When you install the template, IBM Cloud Schematics creates a workspace and starts provisioning your resources by using Terraform. You can review logs and your resources from the IBM Cloud Schematics console. For more information, see the [IBM Cloud Schematics documentation](https://cloud.ibm.com/docs/schematics?topic=schematics-about-schematics).

For more information about IBM Cloud classic virtual service instances, see [Getting started with virtual servers](https://cloud.ibm.com/docs/vsi?topic=virtual-servers-getting-started-tutorial).
For more information about IBM Cloud Databases for PostgreSQL, see [Getting started with Databases for PostgreSQL](https://cloud.ibm.com/docs/services/databases-for-postgresql?topic=databases-for-postgresql-getting-started).

## Costs

This sample uses chargeable services and you are charged for the time the services are deployed. The use of `terraform destroy` results in deletion of all resources including the IBM Cloud database service instance. Billing for virtual server instances and IBM Cloud database terminates on the hour.
When you apply this template, you are charged for the classic virtual server and the database instances that you configure.
- **Classic virtual server instance**: The price for your instance depends on your instance configuration. Make sure to review available [plans](https://www.ibm.com/cloud/virtual-servers/calculator/) before you apply this template in IBM Cloud. By default, your instance is provisioned as a standard virtual server instance with an hourly billing.
- **Databases for PostgreSQL instance**: The price for your database instance depends on the amount of data in gigabytes (GB) that you store. To find available prices per GB, see the [IBM Cloud catalog](https://cloud.ibm.com/catalog/services/databases-for-postgresql). By default, your instance is billed hourly.

**Note**: You can remove your virtual server and database instance by [deleting your Schematics workspace or your instances](https://cloud.ibm.com/docs/schematics?topic=schematics-manage-lifecycle#destroy-resources) with IBM Cloud Schematics. Removing the workspace or the instances cannot be undone. Make sure that you back up any data that you must keep before you start the deletion process.

## Dependencies

The user must have IAM access to create and configure an IBM Cloud database instance and virtual server instances.
Before you can apply the template in IBM Cloud, you must have the following permissions in IBM Cloud Identity and Access Management:
- **Manager** service access role for IBM Cloud Schematics
- **Add Server** and **Cancel Server** classic infrastructure permissions that you can find in the **Account** permission set
- All permissions that are included in the **Devices** classic infrastructure permission set
- **Add Compute with Public Network Port** classic infrastructure permission that you can find in the **Network** permission set
- **Editor** platform role for IBM Cloud Databases for PostgreSQL

## Configuring your deployment values

Set the following variables before you use the template.

* `softlayer_api_key` is a classic infrastructure API key. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys). If you don't have one already, create one and save the API key.
* `softlayer_username` is the infrastructure user name. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys). Click **Details** from the **Actions** menu for your classic infrastructure API key. Copy the API user name for this variable.
* `ibmcloud_api_key` is the IBM Cloud API key for your user identity. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys) to create one.

When you select the VSI-database template from the IBM Cloud catalog, you must enter the following values before you can apply the template:

### Deployment values
* `softlayer_api_key`: Enter the API key to access IBM Cloud classic infrastructure. For more information for how to create an API key and retrieve it, see [Managing classic infrastructure API keys](https://cloud.ibm.com/docs/iam?topic=iam-classic_keys).
* `softlayer_username`: Enter the user name to access IBM Cloud classic infrastructure. You can retrieve the user name by following the instructions for retrieving your classic infrastructure API key.
* `ibmcloud_api_key`: Enter your IBM Cloud API. To create one, go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys).
* `admin-password`: Enter a password for the database administrator. The password must be between 10-32 characters.
* `db-user-password`: Enter a password for the database user that you want to set up. The password must be between 10-32 characters.

You must also set the following deployment values on the Create page. You can enter customized values or accept the defaults.

The example is deployed in the eu-gb region. The `region` parameter in the `provider.tf` file must be set to the same region as the IBM Cloud database instance that it's deployed in, as defined by the `location` parameter on the ibm_database resource.
You can also choose to customize the default settings for your classic infrastructure virtual server or database instance:

|Variable Name|Description|Default Value|
|-------------|-----------|-------------|
|hostname| The hostname for the virtual machine, for example, webapp1.|webapp1|
|domain | The domain for the virtual machine, for example, domain.dev.|domain.dev|
|datacenter | The data center to create the virtual server instance, for example, dal13. To get a list of all data centers, run the `ic sl vs options` command.|dal13|
|os-reference-code | The code that is used to provision the computing instance. To view the available OS reference codes, log in to the [IBM Cloud Infrastructure (SoftLayer) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode).|CENTOS_LATEST_64|
|flavor | The flavor type of the VSI.|C1_1X1X25|
|resource-group | The resource group of the account where services are deployed.||
|resource-instance-name | The unique name for the database instance.|demo-postgres|
|database-service-name | The service name of the database.|databases-for-postgresql|
|database-service-plan | The service plan of the database.|standard|
|location | The location in which to deploy the instance. The region and location must match.|eu-gb|
|admin-password| Enter a password for the database administrator. The password must be between 10-32 characters.||
|members-memory-allocation-mb| The memory size for the database that's split across all members.|3072|
|members-disk-allocation-mb| The disk size of the database that's split across all members.|20480|
|db-user-name| The new database user name.|user123|
|db-user-password| The new database user password. The password must be between 10-32 characters.||

**Note** For more information about the deployment values, go to the following pages:
https://ibm-cloud.github.io/tf-ibm-docs/v0.17.3/r/database.html
https://ibm-cloud.github.io/tf-ibm-docs/v0.17.3/r/compute_vm_instance.html


## Outputs

The composed connection string for the default admin ID for the deployed IBM Cloud database PostgreSQL database is displayed. Connection string usage depends on the type of IBM Cloud database service that is deployed. There might be multiple strings for different hosts in the database cluster. See the [IBM Cloud database documentation](https://cloud.ibm.com/docs/services/databases-for-etcd?topic=databases-for-etcd-connection-strings#connection-strings) for information about the use of connection strings.

## Running the configuration
```shell
terraform init
terraform plan
```

For apply phase

```shell
terraform apply
```

```shell
terraform destroy
```
|hostname| Enter a host name for your classic infrastructure virtual server instance. This host name is used with the `domain` to create the full URL for your classic infrastructure virtual server instance. |webapp1|
|domain | Enter the domain name that you want to assign to your classic infrastructure virtual server instance. This domain name is used with the `hostname` to create the full URL for your classic infrastructure virtual server instance.|domain.dev|
|datacenter | Enter the data center where you want to provision your classic infrastructure virtual server instance. For available data centers, run `ibmcloud sl vs options` and review the values in the **datacenter** field.|dal13|
|os-reference-code | Enter the reference code of the operating system that you want to install on your virtual server instance. To see available OS reference codes, log in to the [IBM Cloud Infrastructure (SoftLayer) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode).|CENTOS_LATEST_64|
|flavor | Enter the flavor for your classic infrastructure virtual server instance. The flavor determines the type of virtual server instance that you want to create, including available CPU and memory. To find a list of supported flavors, run `ibmcloud sl vs options` and review the values in the **flavors** field. For an overview of what is included in each flavor, see [Public virtual servers](https://cloud.ibm.com/docs/vsi?topic=virtual-servers-about-public-virtual-servers).|C1_1X1X25|
|resource-group | Enter the name of the IBM Cloud resource group where you want to provision your database instance. To list available resource groups, run `ibmcloud resource groups`. ||
|resource-instance-name | Enter a unique name for your Databases for PostgreSQL service instance.|demo-postgres|
|database-service-name | Enter the name of the database that you set up within your Databases for PostgreSQL service instance. |databases-for-postgresql|
|database-service-plan | Enter the Databases for PostgreSQL service plan that you want. |standard|
|region | Enter the IBM Cloud region where you want to deploy your Databases for PostgreSQL service instance. The region must match the value in `location`. To find available regions, run `ibmcloud regions`. |
|location | Enter the location, in which to deploy the database instance. The location that you choose must match the value in `region`. To find available locations, run `ibmcloud regions`. |eu-gb|
|members-memory-allocation-mb| Enter the total amount of memory in megabytes that is shared between the database members within the database.|3072|
|members-disk-allocation-mb| Enter the disk size in megabytes for the database that is shared across all database members. |20480|
|db-user-name| Enter the user name of a database user that you want to set up. |user123|

## Output

When you apply the template and your classic virtual server and database instances are successfully provisioned in IBM Cloud, you see the composed database connection string that you can use to connect to your Databases for PostgreSQL service instance by using the `admin` user. For more information about database connection strings, see [Creating Users and Getting Connection Strings](https://cloud.ibm.com/docs/services/databases-for-etcd?topic=databases-for-etcd-connection-strings#connection-string).


8 changes: 4 additions & 4 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
variable "softlayer_username" {
description = "Enter your classic infrastructure user name. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys), and select Details from the Actions menu for your classic infrastructure API key. Then, retrieve your user name."
description = "Enter the user name to access IBM Cloud classic infrastructure. You can retrieve the user name by following the instructions for retrieving your classic infrastructure API key. "
}

variable "softlayer_api_key" {
description = "Enter your classic infrastructure API key. Go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys) to create one, or get an existing one by selecting Details from the Actions menu for the API key."
description = "Enter the API key to access IBM Cloud classic infrastructure. For more information for how to create an API key and retrieve it, see [Managing classic infrastructure API keys](https://cloud.ibm.com/docs/iam?topic=iam-classic_keys). "
}

variable "ibmcloud_api_key" {
description = "Enter your IBM Cloud API key. If you need to create one, go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys)."
description = "Enter your IBM Cloud API. To create one, go to the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys)."
}

variable "region" {
default = "eu-gb"
description = "Region for deploying the instance, for example, eu-gb. To get a list of all regions, run the `ic regions` command."
description = "Enter the IBM Cloud region where you want to deploy your Databases for PostgreSQL service instance. The region must match the value in `location`. To find available regions, run `ibmcloud regions`."
}


Expand Down
31 changes: 15 additions & 16 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
variable "hostname" {
default = "webapp1"
description = "The hostname for the instance, for example, webapp1."
description = "Enter a host name for your classic infrastructure virtual server instance. This host name is used with the `domain` to create the full URL for your classic infrastructure virtual server instance."
}

variable "domain" {
default = "domain.dev"
description = "The domain for the virtual machine, for example, domain.dev."
description = "Enter the domain name that you want to assign to your classic infrastructure virtual server instance. This domain name is used with the `hostname` to create the full URL for your classic infrastructure virtual server instance."
}

variable "datacenter" {
default = "dal13"
description = "The data center to create resources in, for example, dal13. To get a list of all data centers, run the `ic sl vs options` command."
description = "Enter the data center where you want to provision your classic infrastructure virtual server instance. For available data centers, run `ibmcloud sl vs options` and review the values in the 'datacenter' field."
}

variable "os-reference-code" {
default = "CENTOS_LATEST_64"
description = "The code that is used to provision the computing instance. To view the available OS reference codes, log in to the [IBM Cloud Infrastructure (SoftLayer) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode)."
description = "Enter the reference code of the operating system that you want to install on your virtual server instance. To see available OS reference codes, log in to the [IBM Cloud Infrastructure (SoftLayer) API](https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getVhdImportSoftwareDescriptions.json?objectMask=referenceCode)."
}

variable "flavor" {
default = "C1_1X1X25"
description = "The flavor type of the virtual machine."
description = "Enter the flavor for your classic infrastructure virtual server instance. The flavor determines the type of virtual server instance that you want to create, including available CPU and memory. To find a list of supported flavors, run `ibmcloud sl vs options` and review the values in the 'flavors' field. For an overview of what is included in each flavor, see [Public virtual servers](https://cloud.ibm.com/docs/vsi?topic=virtual-servers-about-public-virtual-servers)."
}


variable "resource-group" {
description = "The resource group of the account where services are deployed."
description = "Enter the name of the IBM Cloud resource group where you want to provision your database instance. To list available resource groups, run `ibmcloud resource groups`."
}

variable "resource-instance-name" {
default = "demo-postgres"
description = "The unique name for the database instance."
description = "Enter a unique name for your Databases for PostgreSQL service instance."
}

variable "database-service-name" {
default = "databases-for-postgresql"
description = "The service name of the database."
description = "Enter the name of the database that you set up within your Databases for PostgreSQL service instance."
}

variable "database-service-plan" {
default = "standard"
description = "The service plan of the database."
description = "Enter the Databases for PostgreSQL service plan that you want."
}

variable "location" {
default = "eu-gb"
description = "The location in which to deploy the instance. The region and location must match."
description = "Enter the location, in which to deploy the database instance. The location that you choose must match the value in `region`. To find available locations, run `ibmcloud regions`."
}

variable "admin-password" {
Expand All @@ -54,21 +53,21 @@ variable "admin-password" {

variable "members-memory-allocation-mb"{
default = "3072"
description = "The memory size for the database that's split across all members."
description = "Enter the total amount of memory in megabytes that is shared between the database members within the database."
}


variable "members-disk-allocation-mb"{
default = "20480"
description = "The disk size of the database that's split across all members."
description = "Enter the disk size in megabytes for the database that is shared across all database members."
}


variable "db-user-name"{
default = "user123"
description = "The new database user name."
description = "Enter the user name of a database user that you want to set up. "
}

variable "db-user-password"{
description = "The new database user password."
}
description = "The new database user password. The password must be between 10-32 characters."
}

0 comments on commit 4bef8c1

Please sign in to comment.