# \[ Part 2 ] Deploying the infrastructure

## Steps to be implemented

* initialize the working directory&#x20;
* determine what to be created
* apply the changes

### \[ 1 ] Initialize the working directory

Perform this step by running the Terraform command, "terraform init"

```
zack@cloudshell:MdsReplication (eu-frankfurt-1)$  terraform init
```

### \[ 2 ] Determine what to be created/deployed

Perform this step by running the Terraform command, "terraform plan"

```
zack@cloudshell:MdsReplication (eu-frankfurt-1)$  terraform plan
```

### \[ 3 ] Apply changes

**\[ 3.1 ] Create the compartment**

Perform this step to create the compartment,  by applying resource targetting:

```
terraform apply -target oci_identity_compartment.MySqlOciCompartment
```

**\[ 3.2 ] Create the rest of resources**

Perform this step by running the Terraform command, "terraform apply"

```
zack@cloudshell:MdsReplication (eu-frankfurt-1)$  terraform apply
```

### At this stage, the "terraform apply" will be:

* creating a VCN and compartment, with two subnets - private and public
* creating an Internet Gateway
* creating an Service Gateway
* applying route rules for Service Gateway
* deploying an OCI instance in a public subnet, with firewall rules for ports 22, 3306, 33060 and 3307
* provisioning MySQL service and mysql-shell on OCI instance
* creating a MySQL DB System in a private subnet, with a static private IP (10.0.1.5)
* creating an Object Storage

The Channel will be created in Part 5. The below architecture represents the entire deployment.

![](https://4059461994-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYZtT66GrlnDmIG2g4R%2F-MYa59eiiOGmN8hJ05co%2F-MYa5Mb0ZkYnyB5PGr3W%2Farch_channel1.jpg?alt=media\&token=b71628af-7352-4f64-b6d4-d585e2014d35)
