Skip to content

Commit

Permalink
Merge pull request #279 from junior/terraform_updates
Browse files Browse the repository at this point in the history
Terraform updates
  • Loading branch information
junior authored Jul 6, 2021
2 parents 94df6b1 + 0f093b7 commit 4d7147c
Show file tree
Hide file tree
Showing 22 changed files with 412 additions and 407 deletions.
16 changes: 3 additions & 13 deletions deploy/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,9 @@ This creates a `.zip` file in your working directory that can be imported in to
After complete the Build steps 1 and 2, generate the binaries:
1. From the root of the repo execute the command:
* linux/amd64 (or default builder)
```shell
docker run -v $PWD:/transfer --rm --entrypoint cp mushop-basic:latest /package/mushop-basic.tar.xz /transfer/deploy/basic/terraform/scripts/mushop-basic.tar.xz
```
* linux/arm64
```shell
docker run -v $PWD:/transfer --rm --platform linux/arm64 --entrypoint cp mushop-basic-arm64:latest /package/mushop-basic.tar.xz /transfer/deploy/basic/terraform/scripts/mushop-basic.tar.xz
```
```shell
docker run -v $PWD:/transfer --rm --platform linux/arm64 --entrypoint cp mushop-basic-arm64:latest /basic/PLATFORM.auto.tfvars /transfer/deploy/basic/terraform/PLATFORM.auto.tfvars
```shell
docker run -v $PWD:/transfer --rm --entrypoint cp mushop-basic:latest /package/mushop-basic.tar.xz /transfer/deploy/basic/terraform/scripts/mushop-basic.tar.xz
```
1. Copy mushop media images to populate the object storage:
Expand All @@ -148,6 +137,7 @@ After complete the Build steps 1 and 2, generate the binaries:
1. Change the credentials variables to your user and any other desirable variables
1. Run `terraform init` to init the terraform providers
1. Run `terraform apply` to create the resources on OCI
1. To show sensitive outputs, use `terraform output autonomous_database_password` to show the ATP Admin password and `terraform output generated_private_key_pem` to show the private key for SSH access
[oci]: https://cloud.oracle.com/en_US/cloud-infrastructure
[orm]: https://docs.cloud.oracle.com/iaas/Content/ResourceManager/Concepts/resourcemanager.htm
Expand Down
165 changes: 82 additions & 83 deletions deploy/basic/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions deploy/basic/terraform/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

2021-06-22 (v2.0.0)

- Updated to use Terraform 1.0.x
- Sensitive fields special treatment
- Terraform providers updated to use newer supported versions. (ORM now is supporting the latest)
- Removal of compatibility workarounds for old/deprecated TF providers

2021-06-09 (v1.3.0)

- Multi Architecture Stack (amd64 and Arm64)
Expand Down
2 changes: 1 addition & 1 deletion deploy/basic/terraform/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
2.0.0
118 changes: 54 additions & 64 deletions deploy/basic/terraform/datasources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ data "oci_identity_regions" "home_region" {
provider = oci.current_region
}

# Available Services
data "oci_core_services" "all_services" {
filter {
name = "name"
values = ["All .* Services In Oracle Services Network"]
regex = true
}
}

# Cloud Init
data "template_cloudinit_config" "nodes" {
gzip = true
Expand All @@ -120,79 +129,60 @@ data "template_cloudinit_config" "nodes" {
part {
filename = "cloud-config.yaml"
content_type = "text/cloud-config"
content = data.template_file.cloud_init.rendered
}
}
data "template_file" "cloud_init" {
template = file("${path.module}/scripts/cloud-config.template.yaml")

vars = {
setup_preflight_sh_content = base64gzip(data.template_file.setup_preflight.rendered)
setup_template_sh_content = base64gzip(data.template_file.setup_template.rendered)
deploy_template_content = base64gzip(data.template_file.deploy_template.rendered)
catalogue_sql_template_content = base64gzip(data.template_file.catalogue_sql_template.rendered)
httpd_conf_content = base64gzip(data.local_file.httpd_conf.content)
mushop_media_pars_list_content = base64gzip(data.template_file.mushop_media_pars_list.rendered)
catalogue_password = random_string.catalogue_db_password.result
catalogue_port = local.catalogue_port
catalogue_architecture = split("/", local.compute_platform)[1]
mock_mode = var.services_in_mock_mode
db_name = oci_database_autonomous_database.mushop_autonomous_database.db_name
assets_url = var.object_storage_mushop_media_visibility == "Private" ? "" : "https://objectstorage.${var.region}.oraclecloud.com/n/${oci_objectstorage_bucket.mushop_media.namespace}/b/${oci_objectstorage_bucket.mushop_media.name}/o/"
}
}
data "template_file" "setup_preflight" {
template = file("${path.module}/scripts/setup.preflight.sh")
}
data "template_file" "setup_template" {
template = file("${path.module}/scripts/setup.template.sh")

vars = {
oracle_client_version = var.oracle_client_version
}
}
data "template_file" "deploy_template" {
template = file("${path.module}/scripts/deploy.template.sh")

vars = {
oracle_client_version = var.oracle_client_version
db_name = oci_database_autonomous_database.mushop_autonomous_database.db_name
atp_pw = random_string.autonomous_database_admin_password.result
mushop_media_visibility = var.object_storage_mushop_media_visibility
mushop_app_par = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.mushop_lite_preauth.access_uri}"
wallet_par = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.mushop_wallet_preauth.access_uri}"
content = local.cloud_init
}
}
data "template_file" "catalogue_sql_template" {
template = file("${path.module}/scripts/catalogue.template.sql")

vars = {
catalogue_password = random_string.catalogue_db_password.result
}
}
data "local_file" "httpd_conf" {
filename = "${path.module}/scripts/httpd.conf"
}
data "template_file" "mushop_media_pars_list" {
template = file("./scripts/mushop_media_pars_list.txt")
vars = {
content = local.mushop_media_pars
}
}
## Files and Templatefiles
locals {
httpd_conf = file("${path.module}/scripts/httpd.conf")
setup_preflight = file("${path.module}/scripts/setup.preflight.sh")
setup_template = templatefile("${path.module}/scripts/setup.template.sh",
{
oracle_client_version = var.oracle_client_version
})
deploy_template = templatefile("${path.module}/scripts/deploy.template.sh",
{
oracle_client_version = var.oracle_client_version
db_name = oci_database_autonomous_database.mushop_autonomous_database.db_name
atp_pw = random_string.autonomous_database_admin_password.result
mushop_media_visibility = var.object_storage_mushop_media_visibility
mushop_app_par = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.mushop_lite_preauth.access_uri}"
wallet_par = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.mushop_wallet_preauth.access_uri}"
})
catalogue_sql_template = templatefile("${path.module}/scripts/catalogue.template.sql",
{
catalogue_password = random_string.catalogue_db_password.result
})
mushop_media_pars_list = templatefile("${path.module}/scripts/mushop_media_pars_list.txt",
{
content = local.mushop_media_pars
})
cloud_init = templatefile("${path.module}/scripts/cloud-config.template.yaml",
{
setup_preflight_sh_content = base64gzip(local.setup_preflight)
setup_template_sh_content = base64gzip(local.setup_template)
deploy_template_content = base64gzip(local.deploy_template)
catalogue_sql_template_content = base64gzip(local.catalogue_sql_template)
httpd_conf_content = base64gzip(local.httpd_conf)
mushop_media_pars_list_content = base64gzip(local.mushop_media_pars_list)
catalogue_password = random_string.catalogue_db_password.result
catalogue_port = local.catalogue_port
catalogue_architecture = split("/", local.compute_platform)[1]
mock_mode = var.services_in_mock_mode
db_name = oci_database_autonomous_database.mushop_autonomous_database.db_name
assets_url = var.object_storage_mushop_media_visibility == "Private" ? "" : "https://objectstorage.${var.region}.oraclecloud.com/n/${oci_objectstorage_bucket.mushop_media.namespace}/b/${oci_objectstorage_bucket.mushop_media.name}/o/"
})
}

# Catalogue port
locals {
catalogue_port = 3005
}


# Available Services
data "oci_core_services" "all_services" {
filter {
name = "name"
values = ["All .* Services In Oracle Services Network"]
regex = true
}
}

# Tags
locals {
common_tags = {
Reference = "Created by OCI QuickStart for MuShop Basic demo"
Expand Down
Loading

0 comments on commit 4d7147c

Please sign in to comment.