1+ // Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+ // Licensed under the Mozilla Public License v2.0
3+
4+ variable "tenancy_ocid" {
5+ }
6+
7+ variable "user_ocid" {
8+ }
9+
10+ variable "fingerprint" {
11+ }
12+
13+ variable "private_key_path" {
14+ }
15+
16+ variable "compartment_ocid" {
17+ }
18+
19+ variable "region" {
20+ }
21+
22+ provider "oci" {
23+ region = var. region
24+ tenancy_ocid = var. tenancy_ocid
25+ user_ocid = var. user_ocid
26+ fingerprint = var. fingerprint
27+ private_key_path = var. private_key_path
28+ }
29+
30+ resource "random_string" "topicname" {
31+ length = 10
32+ special = false
33+ }
34+
35+ resource "random_string" "projectname" {
36+ length = 10
37+ special = false
38+ }
39+
40+ resource "oci_ons_notification_topic" "test_notification_topic" {
41+ # Required
42+ compartment_id = var. compartment_ocid
43+ name = random_string. topicname . result
44+ }
45+
46+ resource "oci_devops_project" "test_project" {
47+ # Required
48+ compartment_id = var. compartment_ocid
49+ name = random_string. projectname . result
50+ notification_config {
51+ # Required
52+ topic_id = oci_ons_notification_topic. test_notification_topic . id
53+ }
54+ }
55+
56+ resource "oci_devops_deploy_pipeline" "test_deploy_pipeline" {
57+ # Required
58+ project_id = oci_devops_project. test_project . id
59+
60+ description = " description"
61+ display_name = " displayName"
62+ }
63+
64+ resource "oci_devops_deploy_artifact" "test_deploy_ocir_artifact" {
65+ project_id = oci_devops_project. test_project . id
66+ display_name = " Display_name"
67+ deploy_artifact_type = " DOCKER_IMAGE"
68+ argument_substitution_mode = " NONE"
69+ deploy_artifact_source {
70+ deploy_artifact_source_type = " OCIR"
71+ image_uri = " iad.ocir.io/ax022wvgmjpq/fake/hello-java:0.0.2"
72+ image_digest = " 38598585.fakedigest1"
73+ }
74+ }
75+
76+ resource "oci_devops_deploy_artifact" "test_deploy_generic_artifact" {
77+ argument_substitution_mode = " NONE"
78+ deploy_artifact_source {
79+ deploy_artifact_path = " helloworld-oke.yaml"
80+ deploy_artifact_source_type = " GENERIC_ARTIFACT"
81+ deploy_artifact_version = " v1"
82+ repository_id = " ocid1.artifactrepository.oc1.iad.0.amaaaaaansx72maa7nbce5ebmsqkan3msgyosvxe5d5a6jghn5su6ykgw7vq"
83+ }
84+ deploy_artifact_type = " KUBERNETES_MANIFEST"
85+ project_id = " ${ oci_devops_project . test_project . id } "
86+ }
87+
88+ resource "oci_devops_deploy_environment" "test_deploy_environment" {
89+ # Required
90+ deploy_environment_type = " OKE_CLUSTER"
91+ project_id = oci_devops_project. test_project . id
92+ cluster_id = " ocid1.cluster.oc1.us-ashburn-1.aaaaaaaaafqtkm3fg4zwgnlggmywkzdemi2dcyzymfrdqojygcstocluster1"
93+ display_name = " Display_name"
94+ }
95+
96+ resource "oci_devops_deploy_environment" "test_deploy_function_environment" {
97+ # Required
98+ deploy_environment_type = " FUNCTION"
99+ project_id = oci_devops_project. test_project . id
100+ function_id = " ocid1.fnfunc.oc1.us-ashburn-1.aaaaaaaaafqtkm3fg4zwgnlggmywkzdemi2dcyzymfrdqojygcstofunction1"
101+ display_name = " Display_name"
102+ }
103+
104+ resource "oci_devops_deploy_environment" "test_deploy_instance_group_environment" {
105+ compute_instance_group_selectors {
106+ items {
107+ compute_instance_ids = [" ocid1.instance.oc1.iad.anuwcljtnsx72macffe5fbkzbj4eerle5ot56g2cexj3jvfsr242pye44ghq" ]
108+ selector_type = " INSTANCE_IDS"
109+ }
110+ }
111+ deploy_environment_type = " COMPUTE_INSTANCE_GROUP"
112+ project_id = " ${ oci_devops_project . test_project . id } "
113+ }
114+
115+ resource "oci_devops_deploy_stage" "test_deploy_stage" {
116+ # Required
117+ deploy_pipeline_id = oci_devops_deploy_pipeline. test_deploy_pipeline . id
118+ deploy_stage_predecessor_collection {
119+ # Required
120+ items {
121+ # Required
122+ id = oci_devops_deploy_pipeline. test_deploy_pipeline . id
123+ }
124+ }
125+ deploy_stage_type = " WAIT"
126+
127+ description = " description"
128+ display_name = " displayName"
129+ wait_criteria {
130+ # Required
131+ wait_duration = " PT5S"
132+ wait_type = " ABSOLUTE_WAIT"
133+ }
134+ }
135+
136+ resource "oci_devops_deploy_stage" "test_deploy_stage" {
137+ compute_instance_group_deploy_environment_id = " ${ oci_devops_deploy_environment . test_deploy_instance_group_environment . id } "
138+ defined_tags = " ${ map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " value" )} "
139+ deploy_pipeline_id = " ${ oci_devops_deploy_pipeline . test_deploy_pipeline . id } "
140+ deploy_stage_predecessor_collection {
141+ items {
142+ id = " ${ oci_devops_deploy_pipeline . test_deploy_pipeline . id } "
143+ }
144+ }
145+ deploy_stage_type = " COMPUTE_INSTANCE_GROUP_ROLLING_DEPLOYMENT"
146+ deployment_spec_deploy_artifact_id = " ${ oci_devops_deploy_artifact . test_deploy_generic_artifact . id } "
147+ description = " description"
148+ display_name = " displayName"
149+ failure_policy {
150+ failure_count = " 1"
151+ policy_type = " COMPUTE_INSTANCE_GROUP_FAILURE_POLICY_BY_COUNT"
152+ }
153+ freeform_tags = {
154+ " bar-key" = " value"
155+ }
156+ load_balancer_config {
157+ backend_port = " 8080"
158+ listener_name = " LoadBalancerListener"
159+ load_balancer_id = " ocid1.loadbalancer.oc1.phx.aaaaaaaaafqtkm3fg4zwgnlggmywkzdemi2dcyzymfrdqojygcstofake1"
160+ }
161+ rollback_policy {
162+ policy_type = " AUTOMATED_STAGE_ROLLBACK_POLICY"
163+ }
164+ rollout_policy {
165+ batch_count = " 5"
166+ batch_delay_in_seconds = " 10"
167+ policy_type = " COMPUTE_INSTANCE_GROUP_LINEAR_ROLLOUT_POLICY_BY_COUNT"
168+ }
169+ }
170+
171+
172+ resource "oci_devops_deployment" "test_deployment" {
173+ # Required
174+ deploy_pipeline_id = oci_devops_deploy_pipeline. test_deploy_pipeline . id
175+ deployment_type = " PIPELINE_DEPLOYMENT"
176+
177+ # Optional
178+ display_name = " test_deployment"
179+
180+ }
0 commit comments