diff --git a/.terraform-version b/.terraform-version new file mode 100644 index 0000000..815b3a9 --- /dev/null +++ b/.terraform-version @@ -0,0 +1 @@ +0.14.9 diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 32cb3cf..f27ef5d 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -2,4 +2,4 @@ //noinspection GroovyUnusedAssignment @Library("Infrastructure") _ -withInfraPipeline('payments') {} +withInfraPipeline('paymentsgw') {} diff --git a/main.tf b/main.tf index 3d4e6ce..f7f613a 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,3 @@ -provider "azurerm" { - version = "1.36.1" -} locals { s2sUrl = "http://rpe-service-auth-provider-${var.env}.service.core-compute-${var.env}.internal" # list of the thumbprints of the SSL certificates that should be accepted by the API (gateway) @@ -11,28 +8,28 @@ locals { dummy = "dummy" } data "azurerm_key_vault" "payment_key_vault" { - name = "ccpay-${var.env}" - resource_group_name = "ccpay-${var.env}" + name = join("-", [var.core_product, var.env]) + resource_group_name = join("-", [var.core_product, var.env]) } data "azurerm_key_vault_secret" "s2s_client_secret" { name = "gateway-s2s-client-secret" - key_vault_id = "${data.azurerm_key_vault.payment_key_vault.id}" + key_vault_id = data.azurerm_key_vault.payment_key_vault.id } data "azurerm_key_vault_secret" "s2s_client_id" { name = "gateway-s2s-client-id" - key_vault_id = "${data.azurerm_key_vault.payment_key_vault.id}" + key_vault_id = data.azurerm_key_vault.payment_key_vault.id } data "template_file" "policy_template" { template = "${file("${path.module}/template/api-policy.xml")}" - vars { - allowed_certificate_thumbprints = "${local.thumbprints_in_quotes_str}" - s2s_client_id = "${data.azurerm_key_vault_secret.s2s_client_id.value}" - s2s_client_secret = "${data.azurerm_key_vault_secret.s2s_client_secret.value}" - s2s_base_url = "${local.s2sUrl}" + vars ={ + allowed_certificate_thumbprints = local.thumbprints_in_quotes_str + s2s_client_id = data.azurerm_key_vault_secret.s2s_client_id.value + s2s_client_secret = data.azurerm_key_vault_secret.s2s_client_secret.value + s2s_base_url = local.s2sUrl } } @@ -40,18 +37,18 @@ data "template_file" "api_template" { template = "${file("${path.module}/template/api.json")}" } resource "azurerm_template_deployment" "api" { - template_body = "${data.template_file.api_template.rendered}" - name = "${var.product}-api-${var.env}" + template_body = data.template_file.api_template.rendered + name = join("-", [var.product, "api",var.env]) deployment_mode = "Incremental" - resource_group_name = "core-infra-${var.env}" - count = "${var.env != "preview" ? 1: 0}" + resource_group_name = join("-", ["core-infra", var.env]) + count = var.env != "preview" ? 1: 0 parameters = { - apiManagementServiceName = "core-api-mgmt-${var.env}" - apiName = "${var.product}-api" - apiProductName = "${var.product}" + apiManagementServiceName = join("-", ["core-api-mgmt", var.env]) + apiName = join("-", [var.product, "api"]) + apiProductName = var.product serviceUrl = "http://payment-api-${var.env}.service.core-compute-${var.env}.internal" - apiBasePath = "${local.api_base_path}" - policy = "${data.template_file.policy_template.rendered}" + apiBasePath = local.api_base_path + policy = data.template_file.policy_template.rendered } -} +} \ No newline at end of file diff --git a/state.tf b/state.tf new file mode 100644 index 0000000..d779070 --- /dev/null +++ b/state.tf @@ -0,0 +1,14 @@ +provider "azurerm" { + features {} +} + +terraform { + backend "azurerm" {} + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~> 2.20.0" + } + } +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 5bbedf6..8c9fcb6 100644 --- a/variables.tf +++ b/variables.tf @@ -1,15 +1,24 @@ variable "product" { - type = "string" + type = string default = "payments" } +variable "core_product" { + type = string + default = "ccpay" +} + variable "location" { - type = "string" + type = string default = "UK South" } variable "env" { - type = "string" + type = string +} + +variable "common_tags" { + type = map(string) } variable "tenant_id" { @@ -22,7 +31,7 @@ variable "jenkins_AAD_objectId" { # thumbprint of the SSL certificate for API gateway tests variable api_gateway_test_certificate_thumbprints { - type = "list" + type = list(string) # TODO: remove default and provide environment-specific values default = [] } \ No newline at end of file