Skip to content

Commit

Permalink
API key (#30)
Browse files Browse the repository at this point in the history
* Added possibility to use existing API key
  • Loading branch information
fmeheust authored Mar 13, 2024
1 parent 4cdfa5c commit c56b451
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
6 changes: 3 additions & 3 deletions config-repo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ resource "oci_devops_repository" "config_repo" {
resource "tls_private_key" "rsa_api_key" {
algorithm = "RSA"
rsa_bits = 4096
count = (local.use-image ? 0 : 1)
count = (local.use-image && !var.use_existing_api_key ? 0 : 1)
}

resource "oci_identity_api_key" "user_api_key" {
#Required
key_value = tls_private_key.rsa_api_key[0].public_key_pem
user_id = var.current_user_ocid
count = (local.use-image ? 0 : 1)
count = (local.use-image || var.use_existing_api_key ? 0 : 1)
}

resource "local_file" "api_private_key" {
depends_on = [ tls_private_key.rsa_api_key ]
filename = "${path.module}/api-private-key.pem"
content = tls_private_key.rsa_api_key[0].private_key_pem
content = (var.use_existing_api_key ? base64decode(var.api_key) : tls_private_key.rsa_api_key[0].private_key_pem)
count = (local.use-image ? 0 : 1)
}

Expand Down
13 changes: 13 additions & 0 deletions interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ variableGroups:
###APPLICATION_GROUP###
- title: "Stack authentication"
variables:
- use_existing_api_key
- api_key
- use_existing_vault
- new_vault_display_name
- vault_compartment_id
Expand Down Expand Up @@ -203,6 +205,17 @@ variables:
and:
- use_existing_database
# Vault
use_existing_api_key:
type: boolean
title: Use an existing API key
required: true
default: false
description: The API key will be used to authenticate the user when using the OCI devops repository
api_key:
type: file
title: Private key
required: true
visible: use_existing_api_key
use_existing_vault:
type: boolean
title: Use an existing key vault
Expand Down
10 changes: 5 additions & 5 deletions listing/usage-information.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
</li>
</ul>

<p><strong>Stack authentication</strong>: a Vault is used to store sensitive information such as authentication tokens
and passwords.&nbsp;The stack can either use an existing vault or create a new one.&nbsp;To use an existing key vault,
the stack will let you select the existing vault and key (AES). To create a new vault you must provide
the&nbsp;user-friendly name of the vault to create.</p>
<p><strong>Stack authentication</strong>: the stack uses an API key to connect to the repository. A&nbsp;Vault is used
to store sensitive information such as passwords.&nbsp;The stack can either use an existing vault or create a new
one.&nbsp;To use an existing key vault, the stack will let you select the existing vault and key (AES). To create a
new vault you must provide the&nbsp;user-friendly name of the vault to create.</p>

<p><strong>Database</strong>: The stack assumes that the persistence is handled by a database and this section lets you
configure that database. You can either choose an existing database by selecting the database or create a new one.</p>
Expand Down Expand Up @@ -167,7 +167,7 @@
balancer and the application. If you chose to <em>open the load balancer to the internet</em>, the load balancer
subnet will be a public subnet and an Internet Gateway will be created. A <strong>reserved IP</strong> address can
be used as the load balancer&#39;s public IP.</li>
<li>A c<strong>ertificate</strong> can be provided for the application URL</li>
<li>A <strong>certificate </strong>can be provided for the application URL</li>
</ul>

<p>By default the <em>load balancer</em> is configured with minimum and maximum bandwidth of 10Mbps, the health check
Expand Down
Binary file modified screenshots/7_Vault.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions usage_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ The stack supports different kinds of deployments: *source code* deployment, jav

![](./screenshots/7_Vault.png)


An **API key** is used to authenticate the user when connecting to the code repository. The stack can either create a new API key or use an existing API key if the **private key** is provided.

A **Vault** is used to store sensitive information such as authentication tokens and passwords. The stack can either use an existing vault (which can be in a different compartment) or create a new one.

To use an existing key vault :
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ variable "reserved_ip_address" {
default = ""
}

variable "use_existing_api_key" {
type = bool
default = false
}

variable "api_key" {
type = string
default = "none"
}

locals {
# application name with branch
application_name = (var.branch == "" ? var.application_name : "${var.application_name}-${var.branch}")
Expand Down

0 comments on commit c56b451

Please sign in to comment.