+++
title = "Deploying native Services with the AWS Service Broker"
chapter = false
weight = 4
+++


:imagesdir: /images

This module assumes that the AWS Service Broker is installed and configured.
If you have not already completed this, please complete the installing the service broker module under the administator track

link:https://openshift4-on-aws.awsworkshop.io/3-administrator-track/2-integrations/2-aws-service-broker/55-deploying-services-with-service-broker.html[Installing the AWS Service Broker under the admin track]



Using the OpenShift Serice Catolog to deploy AWS service via a graphical interface.

Step 1:: Connect to the OpenShift web console:

----
This is the same process covered in the getting started module
----

Step 2:: Create a project

----
Under the *developer* context
expland advanced on the left
expand projects
click on create project
create a project called *native*
----

Step 3:: Deploying an AWS S3 bucket using the Broker

The AWS Service broker makes use of prescritive infrastructure as code templates to provision AWS services. The AWS Service broker uses plans which are collections of parameters, with predefined defaults. These prescribed parameter defaults are intended to reduce the amount of infomation a developer would need to input in order to adopt and Service. These can however be over written when provisioning the service, or the defaults can be changed in the infrastructure as code templates. To take it a step further teams can create completely custom templates and a custom catalog of services.

----
Under the add menu select from catalog.
If the AWS service Broker is installed you should see services listed under the Service Class type.
Select Service Class on the left.
   This will filter the catalog to only show services Provided by the AWS Service Broker.
Scroll down  to find Amazon S3.
Click create service instance
Change the Service instance name to <YOUR STUDENT NUMBER S3>
Under plans select production
Click on create
----

The provisioning process is out of band. The oc create api call is passed to the AWS Service broker which in tern performs an API to the AWS CloudFormation service to launch a stack describing the AWS service. While this stack is building within the AWS account The Conditions page will reflect provisioning in progress. The broker will poll the state of the stack. Once the stack is complete the Conditions page will show The instance was provisioned successfully or some other dreadful undesired state. 

All the info needed to consume the AWS Service such as arn, endpoint, URL, usernames, passwords, are passed back to the broker and stored as a secret within OpenShift. This can be used later to bind to applications.

image::brokers3.gif[project]

Step 3:: Clean up

----
Expand advanced on the left
Select projects
Scroll down to find the native project
click in the 3 dot menu on the right
Select delete project
type in native
Click on delete
----

Deleting the project will remove all artifaces from OpenShift including the services provided by the AWS Service Broker. The broker will perform an API call to AWS CloudFormation to delete the stack, removing the AWS services provisioned out of band. To protect against data loss, certain resources will be retained. RDS will create a final snapshot of the database, S3 will retail the bucket in the account, this can be manually removed once data has been moved out of the bucket. These behaviors are defined within the templates and can be customized.


AWS RDS is a relational database service managed by AWS so customers focus on the database and not on the operational overhead. Scalable through simple API calls, resilience through multi AZ implementation.
Lets provision an RDS instance.

Step 4:: Create a project

----
Under the *developer* context
expland advanced on the left
expand projects
click on create project
create a project called *nativedb*
----

Step 5:: Deploying an AWS RDS instance using the Broker

----
Under the add menu select from catalog.
Scroll down  to find Amazon RDS Mysql.
Click create service instance
Change the Service instance name to <YOUR STUDENT NUMBER S3>
Select the developement plan
Add a VPCID (Check with the workshop presenter is this is a specific one)
Chege the Access CIDR to 10.0.0.0/8
Click on create
----

The provisioning will take a few minutes, typically 10 to 15 min, if a small instance type is selected this will take longer to provision. In this lab we have selected the developer plan as this will deploy a single AZ RDS instance to speed up the process during the lab. It is recommended that Multi AZ implementations are used for Prodcution workloads.


Once the message has chnaged to :
The instance was provisioned successfully

Step 6:: Create a service Binding
----
change the name to rdsmysql-<STUDENTNUMBER>
----

In the next lab we will deploy an application which will connect to this database.
The Service Binding will be used to bind the service to the front end application



