Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_nginx_configuration - fix package_data, protected_file validation logic #20491

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions internal/services/nginx/nginx_configuration_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ func (m ConfigurationResource) Arguments() map[string]*pluginsdk.Schema {
},

"config_file": {
Type: pluginsdk.TypeSet,
Required: true,
Type: pluginsdk.TypeSet,
Optional: true,
AtLeastOneOf: []string{"config_file", "package_data"},
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"content": {
Expand All @@ -122,8 +123,9 @@ func (m ConfigurationResource) Arguments() map[string]*pluginsdk.Schema {
},

"protected_file": {
Type: pluginsdk.TypeSet,
Optional: true,
Type: pluginsdk.TypeSet,
Optional: true,
RequiredWith: []string{"config_file"},
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"content": {
Expand All @@ -143,9 +145,11 @@ func (m ConfigurationResource) Arguments() map[string]*pluginsdk.Schema {
},

"package_data": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
AtLeastOneOf: []string{"config_file", "package_data"},
ConflictsWith: []string{"protected_file", "config_file"},
},

"root_file": {
Expand Down
10 changes: 6 additions & 4 deletions website/docs/r/nginx_configuration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ EOT

The following arguments are supported:

* `config_file` - (Required) One or more `config_file` blocks as defined below.

* `nginx_deployment_id` - (Required) The ID of the Nginx Deployment. Changing this forces a new Nginx Configuration to be created.

* `root_file` - (Required) Specify the root file path of this Nginx Configuration.

---

-> **NOTE:** Either `package_data` or `config_file` must be specified - but not both.

* `package_data` - (Optional) Specify the package data for this configuration.

* `protected_file` - (Optional) One or more `config_file` (Protected File) blocks with sensitive information as defined below.
* `config_file` - (Optional) One or more `config_file` blocks as defined below.

* `protected_file` - (Optional) One or more `protected_file` (Protected File) blocks with sensitive information as defined below. If specified `config_file` must also be specified.

---

Expand All @@ -79,7 +81,7 @@ A `config_file` block supports the following:

---

A `config_file` (Protected File) block supports the following:
A `protected_file` (Protected File) block supports the following:

* `content` - (Required) Specifies the base-64 encoded contents of this config file (Sensitive).

Expand Down