From 0bffec53d9ecb5bddc6c0b334857d912e7bd7b19 Mon Sep 17 00:00:00 2001 From: Jason Peterson Date: Fri, 14 Feb 2025 04:29:53 -0500 Subject: [PATCH] Add date-based versioning support for Code Engine (#5951) * Add date-based versioning support for Code Engine * remove provider specific attributes --- .secrets.baseline | 40 ++++++------- examples/ibm-code-engine/README.md | 6 ++ ibm/conns/config.go | 1 + .../data_source_ibm_code_engine_app.go | 53 +++++++++++++++++ .../data_source_ibm_code_engine_app_test.go | 7 ++- ...ata_source_ibm_code_engine_binding_test.go | 1 - ...rce_ibm_code_engine_domain_mapping_test.go | 1 - .../data_source_ibm_code_engine_function.go | 53 +++++++++++++++++ ...ta_source_ibm_code_engine_function_test.go | 15 +---- .../data_source_ibm_code_engine_job.go | 53 +++++++++++++++++ .../data_source_ibm_code_engine_job_test.go | 14 +---- .../resource_ibm_code_engine_app.go | 58 +++++++++++++++++++ .../resource_ibm_code_engine_app_test.go | 8 ++- .../resource_ibm_code_engine_binding_test.go | 1 - ...rce_ibm_code_engine_domain_mapping_test.go | 2 - .../resource_ibm_code_engine_function.go | 58 +++++++++++++++++++ .../resource_ibm_code_engine_function_test.go | 16 ++--- .../resource_ibm_code_engine_job.go | 58 +++++++++++++++++++ .../resource_ibm_code_engine_job_test.go | 16 ++--- website/docs/d/code_engine_app.html.markdown | 16 +++++ .../docs/d/code_engine_function.html.markdown | 16 +++++ website/docs/d/code_engine_job.html.markdown | 16 +++++ website/docs/r/code_engine_app.html.markdown | 15 +++++ .../docs/r/code_engine_binding.html.markdown | 10 ++-- .../docs/r/code_engine_function.html.markdown | 15 +++++ website/docs/r/code_engine_job.html.markdown | 16 ++++- 26 files changed, 480 insertions(+), 85 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 067566607fe..9e81a8fcc06 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2025-01-28T03:10:54Z", + "generated_at": "2025-02-06T19:26:40Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -478,7 +478,7 @@ "hashed_secret": "dc61ac50e6f36d09340d8ca062da1f0d4215004f", "is_secret": false, "is_verified": false, - "line_number": 198, + "line_number": 199, "type": "Secret Keyword", "verified_result": null }, @@ -486,7 +486,7 @@ "hashed_secret": "470851178a9e3a16c35bc88232c21d04c555e5ca", "is_secret": false, "is_verified": false, - "line_number": 270, + "line_number": 271, "type": "Secret Keyword", "verified_result": null } @@ -888,7 +888,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3658, + "line_number": 3659, "type": "Secret Keyword", "verified_result": null }, @@ -896,7 +896,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3671, + "line_number": 3672, "type": "Secret Keyword", "verified_result": null }, @@ -904,7 +904,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3712, + "line_number": 3713, "type": "Secret Keyword", "verified_result": null } @@ -942,7 +942,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 2369, + "line_number": 2370, "type": "Secret Keyword", "verified_result": null }, @@ -950,7 +950,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 2375, + "line_number": 2376, "type": "Secret Keyword", "verified_result": null } @@ -1978,7 +1978,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 453, + "line_number": 506, "type": "Secret Keyword", "verified_result": null } @@ -2016,7 +2016,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 233, + "line_number": 272, "type": "Secret Keyword", "verified_result": null } @@ -2026,7 +2026,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 283, + "line_number": 336, "type": "Secret Keyword", "verified_result": null } @@ -2046,7 +2046,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 741, + "line_number": 785, "type": "Secret Keyword", "verified_result": null }, @@ -2054,7 +2054,7 @@ "hashed_secret": "3c956707ac29b4a200e47fceffa923341eed7e4f", "is_secret": false, "is_verified": false, - "line_number": 1006, + "line_number": 1064, "type": "Secret Keyword", "verified_result": null }, @@ -2062,7 +2062,7 @@ "hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d", "is_secret": false, "is_verified": false, - "line_number": 1327, + "line_number": 1385, "type": "Secret Keyword", "verified_result": null } @@ -2124,7 +2124,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 508, + "line_number": 552, "type": "Secret Keyword", "verified_result": null }, @@ -2132,7 +2132,7 @@ "hashed_secret": "a99bf28e18370eb20e9cc79a1e7f8c379075f69c", "is_secret": false, "is_verified": false, - "line_number": 680, + "line_number": 738, "type": "Secret Keyword", "verified_result": null }, @@ -2140,7 +2140,7 @@ "hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d", "is_secret": false, "is_verified": false, - "line_number": 850, + "line_number": 908, "type": "Secret Keyword", "verified_result": null } @@ -2150,7 +2150,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 482, + "line_number": 526, "type": "Secret Keyword", "verified_result": null }, @@ -2158,7 +2158,7 @@ "hashed_secret": "3c956707ac29b4a200e47fceffa923341eed7e4f", "is_secret": false, "is_verified": false, - "line_number": 670, + "line_number": 728, "type": "Secret Keyword", "verified_result": null }, @@ -2166,7 +2166,7 @@ "hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d", "is_secret": false, "is_verified": false, - "line_number": 885, + "line_number": 943, "type": "Secret Keyword", "verified_result": null } diff --git a/examples/ibm-code-engine/README.md b/examples/ibm-code-engine/README.md index 6a9c2e99279..61eb614bac5 100644 --- a/examples/ibm-code-engine/README.md +++ b/examples/ibm-code-engine/README.md @@ -144,6 +144,7 @@ resource "ibm_code_engine_app" "code_engine_app_instance" { |------|-------------| | build | Reference to a build that is associated with the application. | | build_run | Reference to a build run that is associated with the application. | +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. | | created_at | The timestamp when the resource was created. | | endpoint | Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. | | endpoint_internal | The URL to the app that is only visible within the project. | @@ -334,6 +335,7 @@ resource "ibm_code_engine_function" "code_engine_function_instance" { | Name | Description | |------|-------------| +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. | | created_at | The timestamp when the resource was created. | | endpoint | URL to invoke the function. | | endpoint_internal | URL to function that is only visible within the project. | @@ -388,6 +390,7 @@ resource "ibm_code_engine_job" "code_engine_job_instance" { |------|-------------| | build | Reference to a build that is associated with the job. | | build_run | Reference to a build run that is associated with the job. | +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. | | created_at | The timestamp when the resource was created. | | entity_tag | The version of the job instance, which is used to achieve optimistic locking. | | href | When you provision a new job, a URL is created identifying the location of the instance. | @@ -504,6 +507,7 @@ data "ibm_code_engine_app" "code_engine_app_instance" { |------|-------------| | build | Reference to a build that is associated with the application. | | build_run | Reference to a build run that is associated with the application. | +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. | | created_at | The timestamp when the resource was created. | | endpoint | Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. | | endpoint_internal | The URL to the app that is only visible within the project. | @@ -686,6 +690,7 @@ data "ibm_code_engine_function" "code_engine_function_instance" { | code_main | Specifies the name of the function that should be invoked. | | code_reference | Specifies either a reference to a code bundle or the source code itself. To specify the source code, use the data URL scheme and include the source code as base64 encoded. The data URL scheme is defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). | | code_secret | The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate with a non-public endpoint that is specified as`code_reference`. | +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. | | created_at | The timestamp when the resource was created. | | endpoint | URL to invoke the function. | | endpoint_internal | URL to function that is only visible within the project. | @@ -726,6 +731,7 @@ data "ibm_code_engine_job" "code_engine_job_instance" { |------|-------------| | build | Reference to a build that is associated with the job. | | build_run | Reference to a build run that is associated with the job. | +| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. | | created_at | The timestamp when the resource was created. | | entity_tag | The version of the job instance, which is used to achieve optimistic locking. | | href | When you provision a new job, a URL is created identifying the location of the instance. | diff --git a/ibm/conns/config.go b/ibm/conns/config.go index a8e54e889d0..7f747676cad 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -3593,6 +3593,7 @@ func (c *Config) ClientSession() (interface{}, error) { codeEngineClientOptions := &codeengine.CodeEngineV2Options{ Authenticator: authenticator, URL: EnvFallBack([]string{"IBMCLOUD_CODE_ENGINE_API_ENDPOINT"}, codeEngineEndpoint), + Version: core.StringPtr("2025-01-10"), } // Construct the service client. diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_app.go b/ibm/service/codeengine/data_source_ibm_code_engine_app.go index 7035d9cca7f..9ef6e331936 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_app.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_app.go @@ -45,6 +45,45 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { Computed: true, Description: "Reference to a build run that is associated with the application.", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -404,6 +443,20 @@ func dataSourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceD } } + if !core.IsNil(app.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range app.ComputedEnvVariables { + computedEnvVariablesItemMap, err := DataSourceIbmCodeEngineAppEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting computed_env_variables: %s", err), "(Data) ibm_code_engine_app", "read", "set-computed_env_variables").GetDiag() + } + } + if !core.IsNil(app.CreatedAt) { if err = d.Set("created_at", app.CreatedAt); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_app", "read", "set-created_at").GetDiag() diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go index 9410a51e3bf..f5e88470bbd 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go @@ -42,6 +42,7 @@ func TestAccIbmCodeEngineAppDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", "0"), resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", "300"), + resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), ), }, }, @@ -53,7 +54,7 @@ func TestAccIbmCodeEngineAppDataSourceExtended(t *testing.T) { appName := fmt.Sprintf("tf-data-app-extended-%d", acctest.RandIntRange(10, 1000)) appImagePort := "8080" appManagedDomainMappings := "local_public" - appRunAsUser := "0" + appRunAsUser := "10" appRunServiceAccount := "default" appScaleConcurrency := fmt.Sprintf("%d", acctest.RandIntRange(50, 100)) appScaleConcurrencyTarget := fmt.Sprintf("%d", acctest.RandIntRange(20, 50)) @@ -90,6 +91,8 @@ func TestAccIbmCodeEngineAppDataSourceExtended(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", appScaleMemoryLimit), resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", appScaleMinInstances), resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", appScaleRequestTimeout), + resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), + resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "run_env_variables.#", "1"), ), }, }, @@ -109,7 +112,6 @@ func testAccCheckIbmCodeEngineAppDataSourceConfigBasic(projectID string, appImag lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] @@ -155,7 +157,6 @@ func testAccCheckIbmCodeEngineAppDataSourceConfig(projectID string, appImageRefe lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go index 0caab6d1c75..429a55d13ce 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go @@ -57,7 +57,6 @@ func testAccCheckIbmCodeEngineBindingDataSourceConfigBasic(projectID string, app lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go index 8c71886b345..7afbb231eed 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go @@ -61,7 +61,6 @@ func testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID strin lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_function.go b/ibm/service/codeengine/data_source_ibm_code_engine_function.go index f9778cc2007..2dd832fa62e 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_function.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_function.go @@ -55,6 +55,45 @@ func DataSourceIbmCodeEngineFunction() *schema.Resource { Computed: true, Description: "The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate with a non-public endpoint that is specified as`code_reference`.", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -234,6 +273,20 @@ func dataSourceIbmCodeEngineFunctionRead(context context.Context, d *schema.Reso } } + if !core.IsNil(function.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range function.ComputedEnvVariables { + computedEnvVariablesItemMap, err := DataSourceIbmCodeEngineFunctionEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_function", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting computed_env_variables: %s", err), "(Data) ibm_code_engine_function", "read", "set-computed_env_variables").GetDiag() + } + } + if !core.IsNil(function.CreatedAt) { if err = d.Set("created_at", function.CreatedAt); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_function", "read", "set-created_at").GetDiag() diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_function_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_function_test.go index 9700e13223a..254e2656988 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_function_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_function_test.go @@ -40,6 +40,7 @@ func TestAccIbmCodeEngineFunctionDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", "1"), resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", "60"), resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", "4G"), + resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), ), }, }, @@ -77,6 +78,8 @@ func TestAccIbmCodeEngineFunctionDataSourceExtended(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", functionScaleDownDelay), resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", functionScaleMaxExecutionTime), resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", functionScaleMemoryLimit), + resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), + resource.TestCheckResourceAttr("data.ibm_code_engine_function.code_engine_function_instance", "run_env_variables.#", "1"), ), }, }, @@ -94,12 +97,6 @@ func testAccCheckIbmCodeEngineFunctionDataSourceConfigBasic(projectID string, fu code_reference = "%s" name = "%s" runtime = "%s" - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } data "ibm_code_engine_function" "code_engine_function_instance" { @@ -131,12 +128,6 @@ func testAccCheckIbmCodeEngineFunctionDataSourceConfig(projectID string, functio name = "name" value = "value" } - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } data "ibm_code_engine_function" "code_engine_function_instance" { diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_job.go b/ibm/service/codeengine/data_source_ibm_code_engine_job.go index 1835605dc4d..1e2095523d5 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_job.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_job.go @@ -45,6 +45,45 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { Computed: true, Description: "Reference to a build run that is associated with the job.", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -252,6 +291,20 @@ func dataSourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceD } } + if !core.IsNil(job.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range job.ComputedEnvVariables { + computedEnvVariablesItemMap, err := DataSourceIbmCodeEngineJobEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_job", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting computed_env_variables: %s", err), "(Data) ibm_code_engine_job", "read", "set-computed_env_variables").GetDiag() + } + } + if !core.IsNil(job.CreatedAt) { if err = d.Set("created_at", job.CreatedAt); err != nil { return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_job", "read", "set-created_at").GetDiag() diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go index 6141829e1e0..beddffa6f95 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go @@ -37,6 +37,7 @@ func TestAccIbmCodeEngineJobDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", "7200"), resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", "3"), + resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, }, @@ -74,6 +75,7 @@ func TestAccIbmCodeEngineJobDataSourceExtended(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", jobScaleMaxExecutionTime), resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", jobScaleMemoryLimit), resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", jobScaleRetryLimit), + resource.TestCheckResourceAttr("data.ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, }, @@ -90,12 +92,6 @@ func testAccCheckIbmCodeEngineJobDataSourceConfigBasic(projectID string, jobImag project_id = data.ibm_code_engine_project.code_engine_project_instance.project_id image_reference = "%s" name = "%s" - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } data "ibm_code_engine_job" "code_engine_job_instance" { @@ -122,12 +118,6 @@ func testAccCheckIbmCodeEngineJobDataSourceConfig(projectID string, jobImageRefe scale_max_execution_time = %s scale_memory_limit = "%s" scale_retry_limit = %s - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } data "ibm_code_engine_job" "code_engine_job_instance" { diff --git a/ibm/service/codeengine/resource_ibm_code_engine_app.go b/ibm/service/codeengine/resource_ibm_code_engine_app.go index 1091fffd9ad..e66e5196c28 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_app.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_app.go @@ -340,6 +340,50 @@ func ResourceIbmCodeEngineApp() *schema.Resource { Computed: true, Description: "Reference to a build run that is associated with the application.", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -896,6 +940,20 @@ func resourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceDat return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_app", "read", "set-build_run").GetDiag() } } + if !core.IsNil(app.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range app.ComputedEnvVariables { + computedEnvVariablesItemMap, err := ResourceIbmCodeEngineAppEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_app", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + err = fmt.Errorf("Error setting computed_env_variables: %s", err) + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_app", "read", "set-computed_env_variables").GetDiag() + } + } if !core.IsNil(app.CreatedAt) { if err = d.Set("created_at", app.CreatedAt); err != nil { err = fmt.Errorf("Error setting created_at: %s", err) diff --git a/ibm/service/codeengine/resource_ibm_code_engine_app_test.go b/ibm/service/codeengine/resource_ibm_code_engine_app_test.go index 92e786f94e3..da5ee95b4d3 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_app_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_app_test.go @@ -52,6 +52,7 @@ func TestAccIbmCodeEngineAppBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", "0"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", "300"), + resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), ), }, resource.TestStep{ @@ -73,6 +74,7 @@ func TestAccIbmCodeEngineAppBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", "0"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", "300"), + resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), ), }, }, @@ -85,7 +87,7 @@ func TestAccIbmCodeEngineAppExtended(t *testing.T) { imageReference := "icr.io/codeengine/helloworld" imagePort := "8080" managedDomainMappings := "local_public" - runAsUser := "0" + runAsUser := "10" runServiceAccount := "default" scaleConcurrency := fmt.Sprintf("%d", acctest.RandIntRange(50, 100)) scaleConcurrencyTarget := fmt.Sprintf("%d", acctest.RandIntRange(20, 50)) @@ -141,6 +143,7 @@ func TestAccIbmCodeEngineAppExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", scaleMemoryLimit), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", scaleMinInstances), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", scaleRequestTimeout), + resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), ), }, resource.TestStep{ @@ -163,6 +166,7 @@ func TestAccIbmCodeEngineAppExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", scaleMinInstancesUpdate), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", scaleRequestTimeoutUpdate), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", scaleRequestTimeoutUpdate), + resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"), ), }, resource.TestStep{ @@ -187,7 +191,6 @@ func testAccCheckIbmCodeEngineAppConfigBasic(projectID string, imageReference st lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] @@ -239,7 +242,6 @@ func testAccCheckIbmCodeEngineAppConfig(projectID string, configMapName string, lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go b/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go index da8f76119fc..4b15b3e4a72 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go @@ -69,7 +69,6 @@ func testAccCheckIbmCodeEngineBindingConfigBasic(projectID string, appName strin lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go index 4cd3c3ccf33..94033024757 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go @@ -87,7 +87,6 @@ func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Nam lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] @@ -101,7 +100,6 @@ func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Nam lifecycle { ignore_changes = [ - run_env_variables, probe_liveness, probe_readiness ] diff --git a/ibm/service/codeengine/resource_ibm_code_engine_function.go b/ibm/service/codeengine/resource_ibm_code_engine_function.go index 9d90c56588d..9f30c301704 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_function.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_function.go @@ -162,6 +162,50 @@ func ResourceIbmCodeEngineFunction() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_code_engine_function", "scale_memory_limit"), Description: "Optional amount of memory set for the instance of the function. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -567,6 +611,20 @@ func resourceIbmCodeEngineFunctionRead(context context.Context, d *schema.Resour return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_function", "read", "set-scale_memory_limit").GetDiag() } } + if !core.IsNil(function.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range function.ComputedEnvVariables { + computedEnvVariablesItemMap, err := ResourceIbmCodeEngineFunctionEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_function", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + err = fmt.Errorf("Error setting computed_env_variables: %s", err) + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_function", "read", "set-computed_env_variables").GetDiag() + } + } if !core.IsNil(function.CreatedAt) { if err = d.Set("created_at", function.CreatedAt); err != nil { err = fmt.Errorf("Error setting created_at: %s", err) diff --git a/ibm/service/codeengine/resource_ibm_code_engine_function_test.go b/ibm/service/codeengine/resource_ibm_code_engine_function_test.go index 71101397077..7870bec6136 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_function_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_function_test.go @@ -47,6 +47,7 @@ func TestAccIbmCodeEngineFunctionBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", "1"), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", "60"), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", "4G"), + resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), ), }, resource.TestStep{ @@ -63,6 +64,7 @@ func TestAccIbmCodeEngineFunctionBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", "1"), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", "60"), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", "4G"), + resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), ), }, }, @@ -110,6 +112,7 @@ func TestAccIbmCodeEngineFunctionExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", functionScaleDownDelay), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", functionScaleMaxExecutionTime), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", functionScaleMemoryLimit), + resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), ), }, resource.TestStep{ @@ -126,6 +129,7 @@ func TestAccIbmCodeEngineFunctionExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_down_delay", functionScaleDownDelayUpdate), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_max_execution_time", functionScaleMaxExecutionTimeUpdate), resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "scale_memory_limit", functionScaleMemoryLimitUpdate), + resource.TestCheckResourceAttr("ibm_code_engine_function.code_engine_function_instance", "computed_env_variables.#", "6"), ), }, }, @@ -143,12 +147,6 @@ func testAccCheckIbmCodeEngineFunctionConfigBasic(projectID string, codeReferenc code_reference = "%s" name = "%s" runtime = "%s" - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } `, projectID, codeReference, name, runtime) } @@ -174,12 +172,6 @@ func testAccCheckIbmCodeEngineFunctionConfig(projectID string, codeReference str name = "name" value = "value" } - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } `, projectID, codeReference, managedDomainMappings, name, runtime, scaleCpuLimit, scaleDownDelay, scaleMaxExecutionTime, scaleMemoryLimit) } diff --git a/ibm/service/codeengine/resource_ibm_code_engine_job.go b/ibm/service/codeengine/resource_ibm_code_engine_job.go index f52e8d7fbe1..7dcf992c1f2 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_job.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_job.go @@ -207,6 +207,50 @@ func ResourceIbmCodeEngineJob() *schema.Resource { Computed: true, Description: "Reference to a build run that is associated with the job.", }, + "computed_env_variables": { + Type: schema.TypeList, + Computed: true, + Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The key to reference as environment variable.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the environment variable.", + }, + "prefix": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "A prefix that can be added to all keys of a full secret or config map reference.", + }, + "reference": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The name of the secret or config map.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specify the type of the environment variable.", + }, + "value": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "The literal value of the environment variable.", + }, + }, + }, + }, "created_at": { Type: schema.TypeString, Computed: true, @@ -593,6 +637,20 @@ func resourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceDat return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_job", "read", "set-build_run").GetDiag() } } + if !core.IsNil(job.ComputedEnvVariables) { + computedEnvVariables := []map[string]interface{}{} + for _, computedEnvVariablesItem := range job.ComputedEnvVariables { + computedEnvVariablesItemMap, err := ResourceIbmCodeEngineJobEnvVarToMap(&computedEnvVariablesItem) // #nosec G601 + if err != nil { + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_job", "read", "computed_env_variables-to-map").GetDiag() + } + computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap) + } + if err = d.Set("computed_env_variables", computedEnvVariables); err != nil { + err = fmt.Errorf("Error setting computed_env_variables: %s", err) + return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_code_engine_job", "read", "set-computed_env_variables").GetDiag() + } + } if !core.IsNil(job.CreatedAt) { if err = d.Set("created_at", job.CreatedAt); err != nil { err = fmt.Errorf("Error setting created_at: %s", err) diff --git a/ibm/service/codeengine/resource_ibm_code_engine_job_test.go b/ibm/service/codeengine/resource_ibm_code_engine_job_test.go index 30b285b2a2c..cbc5df56d5a 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_job_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_job_test.go @@ -47,6 +47,7 @@ func TestAccIbmCodeEngineJobBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", "7200"), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", "3"), + resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, resource.TestStep{ @@ -63,6 +64,7 @@ func TestAccIbmCodeEngineJobBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", "7200"), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", "4G"), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", "3"), + resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, }, @@ -116,6 +118,7 @@ func TestAccIbmCodeEngineJobExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", scaleMaxExecutionTime), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", scaleMemoryLimit), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", scaleRetryLimit), + resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, resource.TestStep{ @@ -133,6 +136,7 @@ func TestAccIbmCodeEngineJobExtended(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_max_execution_time", scaleMaxExecutionTimeUpdate), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_memory_limit", scaleMemoryLimitUpdate), resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "scale_retry_limit", scaleRetryLimitUpdate), + resource.TestCheckResourceAttr("ibm_code_engine_job.code_engine_job_instance", "computed_env_variables.#", "3"), ), }, resource.TestStep{ @@ -155,12 +159,6 @@ func testAccCheckIbmCodeEngineJobConfigBasic(projectID string, name string, imag project_id = data.ibm_code_engine_project.code_engine_project_instance.project_id name = "%s" image_reference = "%s" - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } `, projectID, name, imageReference) } @@ -183,12 +181,6 @@ func testAccCheckIbmCodeEngineJobConfig(projectID string, name string, imageRefe scale_max_execution_time = %s scale_memory_limit = "%s" scale_retry_limit = %s - - lifecycle { - ignore_changes = [ - run_env_variables - ] - } } `, projectID, name, imageReference, runAsUser, runMode, runServiceAccount, scaleCpuLimit, scaleEphemeralStorageLimit, scaleMaxExecutionTime, scaleMemoryLimit, scaleRetryLimit) diff --git a/website/docs/d/code_engine_app.html.markdown b/website/docs/d/code_engine_app.html.markdown index 48a5fe711ba..32723c79f2a 100644 --- a/website/docs/d/code_engine_app.html.markdown +++ b/website/docs/d/code_engine_app.html.markdown @@ -41,6 +41,22 @@ After your data source is created, you can read values from the following attrib * `build_run` - (String) Reference to a build run that is associated with the application. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `created_at` - (String) The timestamp when the resource was created. * `endpoint` - (String) Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. diff --git a/website/docs/d/code_engine_function.html.markdown b/website/docs/d/code_engine_function.html.markdown index 350dbb3fdd1..85849d59dff 100644 --- a/website/docs/d/code_engine_function.html.markdown +++ b/website/docs/d/code_engine_function.html.markdown @@ -48,6 +48,22 @@ After your data source is created, you can read values from the following attrib * `code_secret` - (String) The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate with a non-public endpoint that is specified as`code_reference`. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `created_at` - (String) The timestamp when the resource was created. * `endpoint` - (String) URL to invoke the function. diff --git a/website/docs/d/code_engine_job.html.markdown b/website/docs/d/code_engine_job.html.markdown index af3e969263d..513c8a7de3f 100644 --- a/website/docs/d/code_engine_job.html.markdown +++ b/website/docs/d/code_engine_job.html.markdown @@ -41,6 +41,22 @@ After your data source is created, you can read values from the following attrib * `build_run` - (String) Reference to a build run that is associated with the job. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `created_at` - (String) The timestamp when the resource was created. * `entity_tag` - (String) The version of the job instance, which is used to achieve optimistic locking. diff --git a/website/docs/r/code_engine_app.html.markdown b/website/docs/r/code_engine_app.html.markdown index 9db4e5958bc..fdb15ba139f 100644 --- a/website/docs/r/code_engine_app.html.markdown +++ b/website/docs/r/code_engine_app.html.markdown @@ -151,6 +151,21 @@ After your resource is created, you can read values from the listed arguments an * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. * `build` - (String) Reference to a build that is associated with the application. * `build_run` - (String) Reference to a build run that is associated with the application. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `created_at` - (String) The timestamp when the resource was created. * `endpoint` - (String) Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. * `endpoint_internal` - (String) The URL to the app that is only visible within the project. diff --git a/website/docs/r/code_engine_binding.html.markdown b/website/docs/r/code_engine_binding.html.markdown index d3b142b8b15..5186801f736 100644 --- a/website/docs/r/code_engine_binding.html.markdown +++ b/website/docs/r/code_engine_binding.html.markdown @@ -53,7 +53,7 @@ Nested schema for **component**: After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the code_engine_binding. -* `code_engine_binding_id` - (String) The ID of the binding. +* `binding_id` - (String) The ID of the binding. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/.+/`. * `href` - (String) When you provision a new binding, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. @@ -65,15 +65,15 @@ After your resource is created, you can read values from the listed arguments an ## Import You can import the `ibm_code_engine_binding` resource by using `id`. -The `id` property can be formed from `project_id`, and `code_engine_binding_id` in the following format: +The `id` property can be formed from `project_id`, and `binding_id` in the following format:
-<project_id>/<code_engine_binding_id>
+<project_id>/<binding_id>
 
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `code_engine_binding_id`: A string in the format `a172ced-b5f21bc-71ba50c-1638604`. The ID of the binding. +* `binding_id`: A string in the format `a172ced-b5f21bc-71ba50c-1638604`. The ID of the binding. # Syntax
-$ terraform import ibm_code_engine_binding.code_engine_binding <project_id>/<code_engine_binding_id>
+$ terraform import ibm_code_engine_binding.code_engine_binding <project_id>/<binding_id>
 
diff --git a/website/docs/r/code_engine_function.html.markdown b/website/docs/r/code_engine_function.html.markdown index 91ec7863500..63602f177c1 100644 --- a/website/docs/r/code_engine_function.html.markdown +++ b/website/docs/r/code_engine_function.html.markdown @@ -80,6 +80,21 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the code_engine_function. * `function_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `created_at` - (String) The timestamp when the resource was created. * `endpoint` - (String) URL to invoke the function. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. diff --git a/website/docs/r/code_engine_job.html.markdown b/website/docs/r/code_engine_job.html.markdown index a25e8bceacc..5e7c6076790 100644 --- a/website/docs/r/code_engine_job.html.markdown +++ b/website/docs/r/code_engine_job.html.markdown @@ -102,6 +102,21 @@ After your resource is created, you can read values from the listed arguments an * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. * `build` - (String) Reference to a build that is associated with the job. * `build_run` - (String) Reference to a build run that is associated with the job. +* `computed_env_variables` - (List) References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. + * Constraints: The maximum length is `100` items. The minimum length is `0` items. +Nested schema for **computed_env_variables**: + * `key` - (String) The key to reference as environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `name` - (String) The name of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. + * `prefix` - (String) A prefix that can be added to all keys of a full secret or config map reference. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-zA-Z_][a-zA-Z0-9_]*$/`. + * `reference` - (String) The name of the secret or config map. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * `type` - (String) Specify the type of the environment variable. + * Constraints: The default value is `literal`. Allowable values are: `literal`, `config_map_full_reference`, `secret_full_reference`, `config_map_key_reference`, `secret_key_reference`. The value must match regular expression `/^(literal|config_map_full_reference|secret_full_reference|config_map_key_reference|secret_key_reference)$/`. + * `value` - (String) The literal value of the environment variable. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `created_at` - (String) The timestamp when the resource was created. * `entity_tag` - (String) The version of the job instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. @@ -110,7 +125,6 @@ After your resource is created, you can read values from the listed arguments an * `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the job. * Constraints: Allowable values are: `job_v2`. - * `etag` - ETag identifier for code_engine_job. ## Import