Skip to content

Commit dcce0f7

Browse files
marvin659SrividyaKamakshi
authored andcommitted
Added - Support for ZPR security attribute for Functions
1 parent 8aca681 commit dcce0f7

File tree

8 files changed

+37
-3
lines changed

8 files changed

+37
-3
lines changed

examples/functions/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ resource "oci_functions_application" "test_application" {
9090
is_enabled = var.application_trace_config.is_enabled
9191
}
9292
shape = var.application_shape
93+
94+
security_attributes = {
95+
"oracle-zpr.sensitivity.value" = "low"
96+
"oracle-zpr.sensitivity.mode" = "enforce"
97+
}
9398
}
9499

95100
data "oci_functions_applications" "test_applications" {

internal/integrationtest/functions_application_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ var (
4646
"name": acctest.Representation{RepType: acctest.Required, Create: `id`},
4747
"values": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_functions_application.test_application.id}`}},
4848
}
49+
ignoreFunctionsApplicationDefinedTagsChangesRepresentation = map[string]interface{}{
50+
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
51+
}
4952

5053
applicationDisplayName = utils.RandomString(1, utils.CharsetWithoutDigits) + utils.RandomString(13, utils.Charset)
5154

@@ -58,9 +61,11 @@ var (
5861
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
5962
"image_policy_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FunctionsApplicationImagePolicyConfigRepresentation},
6063
"network_security_group_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group1.id}`}, Update: []string{`${oci_core_network_security_group.test_network_security_group2.id}`}},
64+
"security_attributes": acctest.Representation{RepType: acctest.Optional, Create: map[string]map[string]map[string]string{"Oracle-ZPR": {"MaxEgressCount": {"value": "42", "mode": "enforce"}}}, Update: map[string]map[string]map[string]string{"Oracle-ZPR": {"MaxEgressCount": {"value": "42", "mode": "enforce"}}}},
6165
"shape": acctest.Representation{RepType: acctest.Optional, Create: `GENERIC_X86`},
6266
"syslog_url": acctest.Representation{RepType: acctest.Optional, Create: `tcp://syslog.test:80`, Update: `tcp://syslog2.test:80`},
6367
"trace_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FunctionsApplicationTraceConfigRepresentation},
68+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreFunctionsApplicationDefinedTagsChangesRepresentation},
6469
}
6570
FunctionsApplicationImagePolicyConfigRepresentation = map[string]interface{}{
6671
"is_policy_enabled": acctest.Representation{RepType: acctest.Required, Create: `false`, Update: `true`},

internal/service/functions/functions_application_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func (s *FunctionsApplicationDataSourceCrud) SetData() error {
9090
s.D.Set("image_policy_config", nil)
9191
}
9292

93+
s.D.Set("security_attributes", s.Res.SecurityAttributes)
94+
9395
s.D.Set("shape", s.Res.Shape)
9496

9597
s.D.Set("state", s.Res.LifecycleState)

internal/service/functions/functions_application_resource.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ func FunctionsApplicationResource() *schema.Resource {
116116
Type: schema.TypeString,
117117
},
118118
},
119+
"security_attributes": {
120+
Type: schema.TypeMap,
121+
Optional: true,
122+
Computed: true,
123+
Elem: schema.TypeString,
124+
},
119125
"shape": {
120126
Type: schema.TypeString,
121127
Optional: true,
@@ -293,6 +299,10 @@ func (s *FunctionsApplicationResourceCrud) Create() error {
293299
}
294300
}
295301

302+
if securityAttributes, ok := s.D.GetOkExists("security_attributes"); ok {
303+
request.SecurityAttributes = tfresource.MapToSecurityAttributes(securityAttributes.(map[string]interface{}))
304+
}
305+
296306
if shape, ok := s.D.GetOkExists("shape"); ok {
297307
request.Shape = oci_functions.CreateApplicationDetailsShapeEnum(shape.(string))
298308
}
@@ -410,6 +420,10 @@ func (s *FunctionsApplicationResourceCrud) Update() error {
410420
}
411421
}
412422

423+
if securityAttributes, ok := s.D.GetOkExists("security_attributes"); ok {
424+
request.SecurityAttributes = tfresource.MapToSecurityAttributes(securityAttributes.(map[string]interface{}))
425+
}
426+
413427
if syslogUrl, ok := s.D.GetOkExists("syslog_url"); ok {
414428
tmp := syslogUrl.(string)
415429
request.SyslogUrl = &tmp
@@ -478,6 +492,8 @@ func (s *FunctionsApplicationResourceCrud) SetData() error {
478492
}
479493
s.D.Set("network_security_group_ids", schema.NewSet(tfresource.LiteralTypeHashCodeForSets, networkSecurityGroupIds))
480494

495+
s.D.Set("security_attributes", s.Res.SecurityAttributes)
496+
481497
s.D.Set("shape", s.Res.Shape)
482498

483499
s.D.Set("state", s.Res.LifecycleState)

internal/service/functions/functions_applications_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ func (s *FunctionsApplicationsDataSourceCrud) SetData() error {
141141
application["image_policy_config"] = nil
142142
}
143143

144+
application["security_attributes"] = r.SecurityAttributes
145+
144146
application["shape"] = r.Shape
145147

146148
application["state"] = r.LifecycleState

website/docs/d/functions_application.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The following attributes are exported:
4545
* `key_details` - A list of KMS key details.
4646
* `kms_key_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the KMS key that will be used to verify the image signature.
4747
* `network_security_group_ids` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to.
48+
* `security_attributes` - Security attributes for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Oracle-ZPR": {"MaxEgressCount": {"value": "42", "mode": "enforce"}}}`
4849
* `shape` - Valid values are `GENERIC_X86`, `GENERIC_ARM` and `GENERIC_X86_ARM`. Default is `GENERIC_X86`. Setting this to `GENERIC_X86`, will run the functions in the application on X86 processor architecture. Setting this to `GENERIC_ARM`, will run the functions in the application on ARM processor architecture. When set to `GENERIC_X86_ARM`, functions in the application are run on either X86 or ARM processor architecture. Accepted values are: `GENERIC_X86`, `GENERIC_ARM`, `GENERIC_X86_ARM`
4950
* `state` - The current state of the application.
5051
* `subnet_ids` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the application.

website/docs/d/functions_applications.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The following attributes are exported:
5555
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
5656
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the application.
5757
* `network_security_group_ids` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to.
58+
* `security_attributes` - Security attributes for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Oracle-ZPR": {"MaxEgressCount": {"value": "42", "mode": "enforce"}}}`
5859
* `image_policy_config` - Define the image signature verification policy for an application.
5960
* `is_policy_enabled` - Define if image signature verification policy is enabled for the application.
6061
* `key_details` - A list of KMS key details.

website/docs/r/functions_application.html.markdown

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ resource "oci_functions_application" "test_application" {
3838
kms_key_id = oci_kms_key.test_key.id
3939
}
4040
}
41+
security_attributes = var.application_security_attributes
4142
shape = var.application_shape
4243
syslog_url = var.application_syslog_url
4344
trace_config {
@@ -60,11 +61,12 @@ The following arguments are supported:
6061
* `defined_tags` - (Optional) (Updatable) Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
6162
* `display_name` - (Required) The display name of the application. The display name must be unique within the compartment containing the application. Avoid entering confidential information.
6263
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
63-
* `network_security_group_ids` - (Optional) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to.
6464
* `image_policy_config` - (Optional) (Updatable) Define the image signature verification policy for an application.
65-
* `is_policy_enabled` - (Required) (Updatable) Define if image signature verification policy is enabled for the application.
65+
* `is_policy_enabled` - (Required) (Updatable) Define if image signature verification policy is enabled for the application.
6666
* `key_details` - (Optional) (Updatable) A list of KMS key details.
67-
* `kms_key_id` - (Required) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the KMS key that will be used to verify the image signature.
67+
* `kms_key_id` - (Required) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the KMS key that will be used to verify the image signature.
68+
* `network_security_group_ids` - (Optional) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to.
69+
* `security_attributes` - (Optional) (Updatable) Security attributes for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Oracle-ZPR": {"MaxEgressCount": {"value": "42", "mode": "enforce"}}}`
6870
* `shape` - (Optional) Valid values are `GENERIC_X86`, `GENERIC_ARM` and `GENERIC_X86_ARM`. Default is `GENERIC_X86`. Setting this to `GENERIC_X86`, will run the functions in the application on X86 processor architecture. Setting this to `GENERIC_ARM`, will run the functions in the application on ARM processor architecture. When set to `GENERIC_X86_ARM`, functions in the application are run on either X86 or ARM processor architecture. Accepted values are: `GENERIC_X86`, `GENERIC_ARM`, `GENERIC_X86_ARM`
6971
* `subnet_ids` - (Required) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the application.
7072
* `syslog_url` - (Optional) (Updatable) A syslog URL to which to send all function logs. Supports tcp, udp, and tcp+tls. The syslog URL must be reachable from all of the subnets configured for the application. Note: If you enable the Oracle Cloud Infrastructure Logging service for this application, the syslogUrl value is ignored. Function logs are sent to the Oracle Cloud Infrastructure Logging service, and not to the syslog URL. Example: `tcp://logserver.myserver:1234`

0 commit comments

Comments
 (0)