Skip to content

Commit 6148d26

Browse files
authored
Merge branch 'main' into oag-dbat-integration
2 parents f87bb26 + a57c2af commit 6148d26

File tree

58 files changed

+2543
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2543
-76
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<!--
2+
Copyright (c) 2024 Oracle and/or its affiliates.
3+
4+
The Universal Permissive License (UPL), Version 1.0
5+
6+
Subject to the condition set forth below, permission is hereby granted to any
7+
person obtaining a copy of this software, associated documentation and/or data
8+
(collectively the "Software"), free of charge and under any and all copyright
9+
rights in the Software, and any and all patent rights owned or freely
10+
licensable by each licensor hereunder covering either (i) the unmodified
11+
Software as contributed to or provided by such licensor, or (ii) the Larger
12+
Works (as defined below), to deal in both
13+
14+
(a) the Software, and
15+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
one is included with the Software (each a "Larger Work" to which the Software
17+
is contributed by such licensors),
18+
19+
without restriction, including without limitation the rights to copy, create
20+
derivative works of, display, perform, and distribute the Software and make,
21+
use, sell, offer for sale, import, export, have made, and have sold the
22+
Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
either these or other terms.
24+
25+
This license is subject to the following condition:
26+
The above copyright notice and either this complete permission notice or at
27+
a minimum a reference to the UPL must be included in all copies or
28+
substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
37+
-->
38+
39+
# OCI Resource Manager Terraform Stack to create OCI DevOps CI/CD pipelines for OCI Functions
40+
41+
Reviewed: 11.2.2025
42+
43+
# When to use this asset?
44+
45+
Anyone who wants to create OCI DevOps pipelines for OCI Functions using Terraform in OCI Resource manager.
46+
The DevOps project is not specific to any programming language but includes <a href="./files/build_pipeline_specs/">build pipeline specs</a> example files to build and deploy jvm and native Java functions. Source code for a such Function can be found <a href="https://github.com/oracle-devrel/technology-engineering/blob/main/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/README.md">here</a>.
47+
48+
# Author
49+
<a href="https://github.com/mikarinneoracle">mikarinneoracle</a>
50+
51+
# How to use this asset?
52+
53+
Clone this repo locally. In OCI Console click <code>Create Stack</code> under <code>Resource Manager</code> in your project compartment. Drag-n-drop the <a href="./files">files</a> -folder to <code>Stack Configuration</code> (<b>folder type</b>) or click this button below to create the stack on your OCI tenancy:
54+
55+
<p>
56+
57+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/latest/devops-tf-stack.zip)
58+
59+
<p>
60+
Note! OCI DevOps <code>IAM Policies</code> are not part of the stack, please refer to <a href="https://docs.oracle.com/en-us/iaas/Content/devops/using/devops_iampolicies.htm">docs</a> how to create them before running the devops project pipelines.
61+
<p>
62+
63+
### Stack settings
64+
65+
Creating the stack in OCI Resource Manger fill in the vars:
66+
67+
![Stack](./files/stack.jpg)
68+
69+
<ul>
70+
<li><i>initial_image</i> that is used to create the OCI Function as target environment for the OCI DevOps deployment pipeline.
71+
By default it is loaded from Dockerhub, but you can use any X86 arch image if want to replace this</li>
72+
<li><i>docker_user</i> is your OCIR Docker user to push the initial image (above) to OCIR repo for the Function. Replace &lt;namespace&gt; with your <code>tenancy namespace</code>. <code>oracleidentitycloudservice</code> is only used for federated domains/users, not local</li>
73+
<li><i>docker_password</i> is an <code>auth token</code> in your OCI user profile, <i>create one for this</i></li>
74+
</ul>
75+
76+
Docker credentials are only used during the DevOps project creation to push the initial Function image and the DevOps project won't need them after it's been created by Terraform. <i>Hence, you can delete the auth token from your profile after the stack has been run.</i>
77+
<p>
78+
79+
After creation run Stacks's Apply to create the OCI DevOps project.
80+
<p>
81+
The Stack creates only a <i>private subnet</i> in the VCN and hence the Function cannot be called outside the tenancy by default after the build and deploy.
82+
<p>
83+
However, the Function invocation can be done from <code>OCI Cloud Shell</code> either by connecting to the <b>VCN private subnet</b> or to <b>OCI Service Network</b>, both options will work. The invocation can be done as follows using the Stack <code>project_name</code> e.g. :
84+
<pre>
85+
fn invoke helloworldai-java helloworldai-java
86+
</pre>
87+
88+
Since the stack creates the DevOps project with a target Function with the intial image it should already run and return:
89+
<pre>
90+
Hello, world!
91+
</pre>
92+
93+
# Useful Links
94+
95+
- [OCI DevOps](https://www.oracle.com/cloud/cloud-native/devops-service/)
96+
- Oracle Cloud Infrastructure (OCI) DevOps is a continuous integration and continuous delivery (CI/CD) service for development teams building on OCI
97+
- [OCI Functions](https://docs.oracle.com/en-us/iaas/Content/Functions/Concepts/functionsoverview.htm)
98+
- Learn how the Functions service lets you create, run, and scale business logic without managing any infrastructure
99+
- [OCI SDK for Java](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/javasdk.htm)
100+
- The Oracle Cloud Infrastructure SDK for Java enables you to write code to manage Oracle Cloud Infrastructure resources
101+
- [Fn](https://fnproject.io/)
102+
- The Fn project is an open-source container-native serverless platform that you can run anywhere -- any cloud or on-premise. It’s easy to use, supports every programming language, and is extensible and performant
103+
- [OCI Functions with GraalVM](https://github.com/shaunsmith/graalvm-fn-init-images)
104+
- Discover GraalVM Native Image -based functions with this example GitHub repo
105+
- [Oracle](https://www.oracle.com/)
106+
- Oracle Website
107+
108+
## License
109+
110+
Copyright (c) 2024 Oracle and/or its affiliates.
111+
112+
Licensed under the Universal Permissive License (UPL), Version 1.0.
113+
114+
See [LICENSE](LICENSE) for more details.
115+
116+
ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## This configuration was generated by terraform-provider-oci
2+
3+
resource oci_artifacts_container_configuration export_container_configuration {
4+
compartment_id = var.compartment_ocid
5+
is_repository_created_on_first_push = "false"
6+
}
7+
8+
resource oci_artifacts_container_repository export_project {
9+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.compartment_id
10+
11+
display_name = "${var.image_name}"
12+
freeform_tags = {
13+
}
14+
is_immutable = "false"
15+
is_public = "false"
16+
provisioner "local-exec" {
17+
command = "docker login ${var.registry} -u '${var.docker_user}' -p '${var.docker_pwd}' && docker pull ${var.initial_image} && docker tag ${var.initial_image} ${var.registry}/${data.oci_objectstorage_namespace.tenancy_namespace.namespace}/${var.image_name}:1 && docker push ${var.registry}/${data.oci_objectstorage_namespace.tenancy_namespace.namespace}/${var.image_name}:1"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 5000
4+
shell: bash
5+
env:
6+
exportedVariables:
7+
- buildId
8+
steps:
9+
- type: Command
10+
command: |
11+
buildId=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-6 | rev`
12+
echo "Build ID: $buildId"
13+
- type: Command
14+
command: |
15+
docker build -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} .
16+
docker tag ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:$buildId
17+
outputArtifacts:
18+
- name: image-jvm
19+
type: DOCKER_IMAGE
20+
location: ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 5000
4+
shell: bash
5+
env:
6+
exportedVariables:
7+
- buildId
8+
steps:
9+
- type: Command
10+
command: |
11+
buildId=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-6 | rev`
12+
echo "Build ID: $buildId"
13+
- type: Command
14+
command: |
15+
docker build -f Dockerfile.native -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} .
16+
docker tag ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:$buildId
17+
outputArtifacts:
18+
- name: image-native
19+
type: DOCKER_IMAGE
20+
location: ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
## This configuration was generated by terraform-provider-oci
2+
3+
resource oci_core_subnet export_project-private {
4+
#availability_domain = <<Optional value not found in discovery>>
5+
cidr_block = "10.0.0.0/24"
6+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
7+
8+
#dhcp_options_id = <<Optional value not found in discovery>>
9+
display_name = "${var.project_name}-private"
10+
#dns_label = <<Optional value not found in discovery>>
11+
freeform_tags = {
12+
}
13+
#ipv6cidr_block = <<Optional value not found in discovery>>
14+
ipv6cidr_blocks = [
15+
]
16+
prohibit_internet_ingress = "true"
17+
prohibit_public_ip_on_vnic = "true"
18+
route_table_id = oci_core_vcn.export_project_3.default_route_table_id
19+
security_list_ids = [
20+
oci_core_default_security_list.export_Default-Security-List-for-project.id,
21+
]
22+
vcn_id = oci_core_vcn.export_project_3.id
23+
}
24+
25+
resource oci_core_default_security_list export_Default-Security-List-for-project {
26+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
27+
28+
display_name = "Default Security List for ${var.project_name}"
29+
egress_security_rules {
30+
#description = <<Optional value not found in discovery>>
31+
destination = "0.0.0.0/0"
32+
destination_type = "CIDR_BLOCK"
33+
#icmp_options = <<Optional value not found in discovery>>
34+
protocol = "all"
35+
stateless = "false"
36+
#tcp_options = <<Optional value not found in discovery>>
37+
#udp_options = <<Optional value not found in discovery>>
38+
}
39+
freeform_tags = {
40+
}
41+
ingress_security_rules {
42+
#description = <<Optional value not found in discovery>>
43+
#icmp_options = <<Optional value not found in discovery>>
44+
protocol = "6"
45+
source = "0.0.0.0/0"
46+
source_type = "CIDR_BLOCK"
47+
stateless = "false"
48+
tcp_options {
49+
max = "22"
50+
min = "22"
51+
#source_port_range = <<Optional value not found in discovery>>
52+
}
53+
#udp_options = <<Optional value not found in discovery>>
54+
}
55+
ingress_security_rules {
56+
#description = <<Optional value not found in discovery>>
57+
icmp_options {
58+
code = "4"
59+
type = "3"
60+
}
61+
protocol = "1"
62+
source = "0.0.0.0/0"
63+
source_type = "CIDR_BLOCK"
64+
stateless = "false"
65+
#tcp_options = <<Optional value not found in discovery>>
66+
#udp_options = <<Optional value not found in discovery>>
67+
}
68+
ingress_security_rules {
69+
#description = <<Optional value not found in discovery>>
70+
icmp_options {
71+
code = "-1"
72+
type = "3"
73+
}
74+
protocol = "1"
75+
source = "10.0.0.0/16"
76+
source_type = "CIDR_BLOCK"
77+
stateless = "false"
78+
#tcp_options = <<Optional value not found in discovery>>
79+
#udp_options = <<Optional value not found in discovery>>
80+
}
81+
manage_default_resource_id = oci_core_vcn.export_project_3.default_security_list_id
82+
}
83+
84+
resource oci_core_vcn export_project_3 {
85+
#byoipv6cidr_details = <<Optional value not found in discovery>>
86+
#cidr_block = <<Optional value not found in discovery>>
87+
cidr_blocks = [
88+
"10.0.0.0/16",
89+
]
90+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
91+
92+
display_name = "${var.project_name}"
93+
#dns_label = <<Optional value not found in discovery>>
94+
freeform_tags = {
95+
}
96+
ipv6private_cidr_blocks = [
97+
]
98+
#is_ipv6enabled = <<Optional value not found in discovery>>
99+
#is_oracle_gua_allocation_enabled = <<Optional value not found in discovery>>
100+
security_attributes = {
101+
}
102+
}
103+
104+
resource oci_core_default_route_table export_Default-Route-Table-for-project {
105+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
106+
107+
display_name = "Default Route Table for ${var.project_name}"
108+
freeform_tags = {
109+
}
110+
manage_default_resource_id = oci_core_vcn.export_project_3.default_route_table_id
111+
route_rules {
112+
#description = <<Optional value not found in discovery>>
113+
destination = "all-fra-services-in-oracle-services-network"
114+
destination_type = "SERVICE_CIDR_BLOCK"
115+
network_entity_id = oci_core_service_gateway.export_svc-gw.id
116+
#route_type = <<Optional value not found in discovery>>
117+
}
118+
}
119+
120+
data "oci_core_services" "all_oci_services" {
121+
filter {
122+
name = "name"
123+
values = ["All .* Services In Oracle Services Network"]
124+
regex = true
125+
}
126+
count = 1
127+
}
128+
129+
resource oci_core_service_gateway export_svc-gw {
130+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
131+
132+
display_name = "${var.project_name}-svc-gw"
133+
freeform_tags = {
134+
}
135+
#route_table_id = <<Optional value not found in discovery>>
136+
services {
137+
service_id = lookup(data.oci_core_services.all_oci_services[0].services[0], "id")
138+
}
139+
vcn_id = oci_core_vcn.export_project_3.id
140+
}
141+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "oci_objectstorage_namespace" "tenancy_namespace" {
2+
compartment_id = oci_artifacts_container_configuration.export_container_configuration.id
3+
}

0 commit comments

Comments
 (0)