Skip to content

Commit

Permalink
Merge pull request #18 from companieshouse/feature/tnsnames-cloud-init
Browse files Browse the repository at this point in the history
Construct Oracle Database config at instance startup
  • Loading branch information
marcransome authored Apr 30, 2021
2 parents 1f0e900 + 0b4f20d commit aab66ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions groups/frontend/cloud-init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ data "template_cloudinit_config" "config" {
content = templatefile("${path.module}/cloud-init/templates/system-config.yml.tpl", {})
}

part {
content_type = "text/cloud-config"
content = templatefile("${path.module}/cloud-init/templates/tnsnames.ora.tpl", {
tnsnames = jsondecode(data.vault_generic_secret.tns_names.data.tnsnames)
})
merge_type = var.user_data_merge_strategy
}

part {
content_type = "text/cloud-config"
content = templatefile("${path.module}/cloud-init/templates/bootstrap-commands.yml.tpl", {
Expand Down
16 changes: 16 additions & 0 deletions groups/frontend/cloud-init/templates/tnsnames.ora.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
write_files:
- path: /opt/oracle/10.2.0/network/admin/tnsnames.ora
owner: root:root
permissions: 0644
content: |
%{ for db in tnsnames }${ db.name } =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ${ db.address })(PORT = ${ db.port }))
)
(CONNECT_DATA =
(SERVICE_NAME = ${ db.service_name })
(SERVER = DEDICATED)
)
)
%{ endfor }
4 changes: 4 additions & 0 deletions groups/frontend/secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ data "vault_generic_secret" "security_s3_buckets" {
data "vault_generic_secret" "security_kms_keys" {
path = "aws-accounts/security/kms"
}

data "vault_generic_secret" "tns_names" {
path = "applications/${var.aws_account}-${var.region}/tuxedo/tnsnames"
}

0 comments on commit aab66ba

Please sign in to comment.