|
| 1 | +/* |
| 2 | +This example demonstrates the various ways a helm chart artifact can be created and specifically, |
| 3 | +the options available for having a signed helm chart verified per |
| 4 | +https://helm.sh/docs/topics/provenance/. |
| 5 | +*/ |
| 6 | + |
| 7 | +variable "tenancy_ocid" { |
| 8 | +} |
| 9 | + |
| 10 | +variable "user_ocid" { |
| 11 | +} |
| 12 | + |
| 13 | +variable "fingerprint" { |
| 14 | +} |
| 15 | + |
| 16 | +variable "private_key_path" { |
| 17 | +} |
| 18 | + |
| 19 | +variable "region" { |
| 20 | +} |
| 21 | + |
| 22 | +variable "vault_secret_public_key_ocid" { |
| 23 | +} |
| 24 | + |
| 25 | +provider "oci" { |
| 26 | + region = var.region |
| 27 | + tenancy_ocid = var.tenancy_ocid |
| 28 | + user_ocid = var.user_ocid |
| 29 | + fingerprint = var.fingerprint |
| 30 | + private_key_path = var.private_key_path |
| 31 | +} |
| 32 | + |
| 33 | + |
| 34 | +# OCID of the DevOps project. |
| 35 | +variable "project_id" { |
| 36 | +} |
| 37 | + |
| 38 | + |
| 39 | +locals { |
| 40 | + chart_url = "oci://iad.ocir.io/namespace/repository/chart-name" |
| 41 | + chart_version = "0.0.1" |
| 42 | + vault_secret_public_key_ocid = var.vault_secret_public_key_ocid |
| 43 | + public_key = "" // Add the public key here |
| 44 | +} |
| 45 | + |
| 46 | + |
| 47 | +resource "oci_devops_deploy_artifact" "helm_chart_implicit_no_public_key" { |
| 48 | + #Required |
| 49 | + argument_substitution_mode = "SUBSTITUTE_PLACEHOLDERS" |
| 50 | + deploy_artifact_source { |
| 51 | + #Required |
| 52 | + deploy_artifact_source_type = "HELM_CHART" |
| 53 | + |
| 54 | + #Optional |
| 55 | + chart_url = local.chart_url |
| 56 | + deploy_artifact_version = local.chart_version |
| 57 | + } |
| 58 | + deploy_artifact_type = "HELM_CHART" |
| 59 | + project_id = var.project_id |
| 60 | + |
| 61 | + #Optional |
| 62 | + description = "helm chart artifact with no public key" |
| 63 | + display_name = "helmChartWithImplicitNoPublicKey" |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | +resource "oci_devops_deploy_artifact" "helm_chart_no_public_key" { |
| 68 | + #Required |
| 69 | + argument_substitution_mode = "SUBSTITUTE_PLACEHOLDERS" |
| 70 | + deploy_artifact_source { |
| 71 | + #Required |
| 72 | + deploy_artifact_source_type = "HELM_CHART" |
| 73 | + |
| 74 | + #Optional |
| 75 | + chart_url = local.chart_url |
| 76 | + deploy_artifact_version = local.chart_version |
| 77 | + |
| 78 | + helm_verification_key_source { |
| 79 | + verification_key_source_type = "NONE" |
| 80 | + } |
| 81 | + } |
| 82 | + deploy_artifact_type = "HELM_CHART" |
| 83 | + project_id = var.project_id |
| 84 | + |
| 85 | + #Optional |
| 86 | + description = "helm chart artifact with no public key" |
| 87 | + display_name = "helmChartWithNoPublicKey" |
| 88 | + |
| 89 | +} |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +resource "oci_devops_deploy_artifact" "helm_chart_vault_public_key" { |
| 94 | + #Required |
| 95 | + argument_substitution_mode = "SUBSTITUTE_PLACEHOLDERS" |
| 96 | + deploy_artifact_source { |
| 97 | + #Required |
| 98 | + deploy_artifact_source_type = "HELM_CHART" |
| 99 | + |
| 100 | + #Optional |
| 101 | + chart_url = local.chart_url |
| 102 | + deploy_artifact_version = local.chart_version |
| 103 | + |
| 104 | + helm_verification_key_source { |
| 105 | + verification_key_source_type = "VAULT_SECRET" |
| 106 | + vault_secret_id = local.vault_secret_public_key_ocid |
| 107 | + } |
| 108 | + } |
| 109 | + deploy_artifact_type = "HELM_CHART" |
| 110 | + project_id = var.project_id |
| 111 | + |
| 112 | + #Optional |
| 113 | + description = "helm chart artifact with vault public key" |
| 114 | + display_name = "helmChartVaultPublicKey" |
| 115 | + |
| 116 | + |
| 117 | +} |
| 118 | + |
| 119 | + |
| 120 | +resource "oci_devops_deploy_artifact" "helm_chart_inline_public_key" { |
| 121 | + #Required |
| 122 | + argument_substitution_mode = "SUBSTITUTE_PLACEHOLDERS" |
| 123 | + deploy_artifact_source { |
| 124 | + #Required |
| 125 | + deploy_artifact_source_type = "HELM_CHART" |
| 126 | + |
| 127 | + #Optional |
| 128 | + chart_url = local.chart_url |
| 129 | + deploy_artifact_version = local.chart_version |
| 130 | + |
| 131 | + helm_verification_key_source { |
| 132 | + verification_key_source_type = "INLINE_PUBLIC_KEY" |
| 133 | + current_public_key = local.public_key |
| 134 | + previous_public_key = local.public_key |
| 135 | + } |
| 136 | + } |
| 137 | + deploy_artifact_type = "HELM_CHART" |
| 138 | + project_id = var.project_id |
| 139 | + |
| 140 | + #Optional |
| 141 | + description = "helm chart artifact with inline public keys" |
| 142 | + display_name = "helmChartInlinePublicKeys" |
| 143 | + |
| 144 | +} |
| 145 | + |
| 146 | +data "oci_devops_deploy_artifact" "retrieve_artifact_with_vault_public_key" { |
| 147 | + deploy_artifact_id = oci_devops_deploy_artifact.helm_chart_vault_public_key.id |
| 148 | +} |
| 149 | + |
| 150 | +data "oci_devops_deploy_artifact" "retrieve_artifact_with_inline_public_key" { |
| 151 | + deploy_artifact_id = oci_devops_deploy_artifact.helm_chart_inline_public_key.id |
| 152 | +} |
| 153 | + |
| 154 | +data "oci_devops_deploy_artifact" "retrieve_artifact_with_no_public_key" { |
| 155 | + deploy_artifact_id = oci_devops_deploy_artifact.helm_chart_no_public_key.id |
| 156 | +} |
| 157 | + |
| 158 | +data "oci_devops_deploy_artifact" "retrieve_artifact_implicit_no_public_key" { |
| 159 | + deploy_artifact_id = oci_devops_deploy_artifact.helm_chart_implicit_no_public_key.id |
| 160 | +} |
| 161 | + |
| 162 | + |
| 163 | +output helm_chart_implicit_no_public_key { |
| 164 | + value = data.oci_devops_deploy_artifact.retrieve_artifact_implicit_no_public_key |
| 165 | +} |
| 166 | + |
| 167 | +output helm_chart_no_public_key { |
| 168 | + value = data.oci_devops_deploy_artifact.retrieve_artifact_with_no_public_key |
| 169 | +} |
| 170 | + |
| 171 | +output helm_chart_vault_public_key { |
| 172 | + value = data.oci_devops_deploy_artifact.retrieve_artifact_with_vault_public_key |
| 173 | +} |
| 174 | + |
| 175 | +output helm_chart_inline_public_key { |
| 176 | + value = data.oci_devops_deploy_artifact.retrieve_artifact_with_inline_public_key |
| 177 | +} |
| 178 | + |
0 commit comments