Skip to content

Commit 4cdfa5c

Browse files
authored
Reserved ip (#29)
* Reserved IP addresses
1 parent 2062897 commit 4cdfa5c

File tree

4 files changed

+17
-37
lines changed

4 files changed

+17
-37
lines changed

config-repo.tf

+13-28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# creates the git repo called "config-repo"
1010
resource "oci_devops_repository" "config_repo" {
11+
depends_on = [ oci_identity_api_key.user_api_key ]
1112
name = local.config_repo_name
1213
project_id = local.project_id
1314
repository_type = "HOSTED"
@@ -19,18 +20,21 @@ resource "oci_devops_repository" "config_repo" {
1920
resource "tls_private_key" "rsa_api_key" {
2021
algorithm = "RSA"
2122
rsa_bits = 4096
23+
count = (local.use-image ? 0 : 1)
2224
}
2325

2426
resource "oci_identity_api_key" "user_api_key" {
25-
#Required
26-
key_value = tls_private_key.rsa_api_key.public_key_pem
27-
user_id = var.current_user_ocid
27+
#Required
28+
key_value = tls_private_key.rsa_api_key[0].public_key_pem
29+
user_id = var.current_user_ocid
30+
count = (local.use-image ? 0 : 1)
2831
}
2932

3033
resource "local_file" "api_private_key" {
3134
depends_on = [ tls_private_key.rsa_api_key ]
3235
filename = "${path.module}/api-private-key.pem"
33-
content = tls_private_key.rsa_api_key.private_key_pem
36+
content = tls_private_key.rsa_api_key[0].private_key_pem
37+
count = (local.use-image ? 0 : 1)
3438
}
3539

3640
resource "local_file" "ssh_config" {
@@ -95,6 +99,7 @@ resource "null_resource" "create_config_repo" {
9599
local_file.self_signed_certificate,
96100
local_file.oci_build_config,
97101
local_file.ssh_config,
102+
local_file.api_private_key,
98103
random_password.wallet_password
99104
]
100105

@@ -105,46 +110,26 @@ resource "null_resource" "create_config_repo" {
105110
working_dir = "${path.module}"
106111
}
107112

108-
# copy private key
109-
provisioner "local-exec" {
110-
command = "cp api-private-key.pem ~/.ssh/private-key.pem"
111-
on_failure = fail
112-
working_dir = "${path.module}"
113-
}
114-
115113
# copy ssh-config
116114
provisioner "local-exec" {
117115
command = "cp ssh_config ~/.ssh/config"
118116
on_failure = fail
119117
working_dir = "${path.module}"
120118
}
121-
122-
provisioner "local-exec" {
123-
command = "less ~/.ssh/config"
124-
on_failure = fail
125-
working_dir = "${path.module}"
126-
}
127-
128-
provisioner "local-exec" {
129-
command = "less ~/.ssh/private-key.pem"
130-
on_failure = fail
131-
working_dir = "${path.module}"
132-
}
133-
134119
provisioner "local-exec" {
135-
command = "chmod 400 ~/.ssh/private-key.pem"
120+
command = "chmod 600 ~/.ssh/config"
136121
on_failure = fail
137122
working_dir = "${path.module}"
138123
}
139124

125+
# copy private key
140126
provisioner "local-exec" {
141-
command = "chmod 600 ~/.ssh/config"
127+
command = "cp api-private-key.pem ~/.ssh/api-private-key.pem"
142128
on_failure = fail
143129
working_dir = "${path.module}"
144130
}
145-
146131
provisioner "local-exec" {
147-
command = "ls -lai ~/.ssh"
132+
command = "chmod 400 ~/.ssh/api-private-key.pem"
148133
on_failure = fail
149134
working_dir = "${path.module}"
150135
}

datasources.tf

-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ data "template_file" "deploy_script" {
8585
}
8686

8787
data "template_file" "ssh_config" {
88-
depends_on = [
89-
local_file.api_private_key
90-
]
9188
template = "${file("${path.module}/ssh_config.template")}"
9289
vars = {
9390
"user" = local.ssh_login

listing/usage-information.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
the stack will let you select the existing vault and key (AES). To create a new vault you must provide
5757
the&nbsp;user-friendly name of the vault to create.</p>
5858

59-
<p>An <strong>authentication token</strong> is used by the stack to authenticate the user when connecting to the code
60-
repository or container registry. This token can either be provided or created by the stack.</p>
61-
6259
<p><strong>Database</strong>: The stack assumes that the persistence is handled by a database and this section lets you
6360
configure that database. You can either choose an existing database by selecting the database or create a new one.</p>
6461

@@ -152,7 +149,6 @@
152149
<li><strong>DNS zone</strong>: homain name managed in OCI DNS.</li>
153150
<li><strong>Host name</strong>: host name that will be created on the selected Zone and will resolve to the the load
154151
balancer&#39;s IP address.</li>
155-
<li><strong>Certificate OCID</strong>: certificate for the application URL</li>
156152
</ul>
157153

158154
<p><strong>Network</strong>: The stack is designed to create all of its resources in the same VCN. You have the choice
@@ -169,7 +165,9 @@
169165
<li>The <strong>load balancer subnet </strong>can either be private (accessible from inside OCI) or public (accessible
170166
from both OCI and the Internet). A NSG will be created and configured to allow the communication between the load
171167
balancer and the application. If you chose to <em>open the load balancer to the internet</em>, the load balancer
172-
subnet will be a public subnet and an Internet Gateway will be created.</li>
168+
subnet will be a public subnet and an Internet Gateway will be created. A <strong>reserved IP</strong> address can
169+
be used as the load balancer&#39;s public IP.</li>
170+
<li>A c<strong>ertificate</strong> can be provided for the application URL</li>
173171
</ul>
174172

175173
<p>By default the <em>load balancer</em> is configured with minimum and maximum bandwidth of 10Mbps, the health check

ssh_config.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Host devops.scmservice.*.oci.oraclecloud.com
22
User ${user}
3-
IdentityFile ~/.ssh/private-key.pem
3+
IdentityFile ~/.ssh/api-private-key.pem

0 commit comments

Comments
 (0)