Skip to content

Commit

Permalink
Add suppression for import warning (Azure#2962)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite authored Jul 1, 2024
1 parent 8b634c4 commit 149c0aa
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 99 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"failover",
"GREATEROREQUAL",
"GREATEROREQUALS",
"hackathons",
"Hashtable",
"inheritdoc",
"konnectivity",
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ What's changed since pre-release v1.38.0-B0034:
[#2922](https://github.com/Azure/PSRule.Rules.Azure/issues/2922)
- Fixed group by subscription casing when exporting in-flight resources by @BernieWhite.
[#2957](https://github.com/Azure/PSRule.Rules.Azure/issues/2957)
- Fixed install Az.Resources warning by @BernieWhite.
[#2887](https://github.com/Azure/PSRule.Rules.Azure/issues/2887)
- Added new configuration option set by environment variable to suppress the warning.
- Set `PSRULE_AZURE_RESOURCE_MODULE_NOWARN` to `true` to suppress the warning.

## v1.38.0-B0034 (pre-release)

Expand Down
20 changes: 20 additions & 0 deletions docs/assets/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:root {
--md-admonition-icon--experimental: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M8 8.807V3.5h-.563a.75.75 0 0 1 0-1.5h9.125a.75.75 0 0 1 0 1.5H16v5.307l5.125 9.301c.964 1.75-.302 3.892-2.299 3.892H5.174c-1.998 0-3.263-2.142-2.3-3.892L8 8.807zM14.5 3.5h-5V9a.75.75 0 0 1-.093.362L7.127 13.5h9.746l-2.28-4.138A.75.75 0 0 1 14.5 9V3.5zM4.189 18.832 6.3 15h11.4l2.111 3.832a1.125 1.125 0 0 1-.985 1.668H5.174a1.125 1.125 0 0 1-.985-1.668z"/></svg>');
--md-admonition-icon--learn: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M12.292 2.06v-.001l11.25 4.75a.749.749 0 0 1 0 1.382L19 10.108V15a.75.75 0 0 1-.11.391h-.001a2.84 2.84 0 0 1-.392.482c-.249.256-.625.58-1.163.896-1.08.638-2.776 1.23-5.334 1.23-.673 0-1.286-.041-1.846-.113a.75.75 0 0 1 .192-1.487c.492.063 1.042.1 1.654.1 2.317 0 3.746-.533 4.572-1.021.31-.178.596-.397.849-.65l.079-.085V10.74l-5.208 2.2a.75.75 0 0 1-.584 0L5.75 10.424v3.17c.502.129.96.391 1.327.758.579.578.923 1.41.923 2.428v4.5a.761.761 0 0 1-.345.634 2.157 2.157 0 0 1-.21.117 3.923 3.923 0 0 1-.52.213A6.121 6.121 0 0 1 5 22.532a6.092 6.092 0 0 1-1.925-.288 4.065 4.065 0 0 1-.52-.213 1.816 1.816 0 0 1-.22-.124.757.757 0 0 1-.335-.624v-4.5c0-1.02.344-1.85.923-2.43a2.904 2.904 0 0 1 1.327-.757V9.793L.458 8.19a.75.75 0 0 1 0-1.38l11.25-4.75a.75.75 0 0 1 .584 0ZM12 11.436 21.322 7.5 12 3.564 2.678 7.5ZM5 15c-.377 0-.745.141-1.017.413-.265.265-.483.7-.483 1.368v4.022c.299.105.797.228 1.5.228s1.201-.123 1.5-.228V16.78c0-.669-.218-1.103-.483-1.368A1.433 1.433 0 0 0 5 15Z"></path></svg>');
--md-admonition-icon--message: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 4.75C0 3.784.784 3 1.75 3h20.5c.966 0 1.75.784 1.75 1.75v14.5A1.75 1.75 0 0 1 22.25 21H1.75A1.75 1.75 0 0 1 0 19.25Zm1.75-.25a.25.25 0 0 0-.25.25v14.5c0 .138.112.25.25.25h20.5a.25.25 0 0 0 .25-.25V4.75a.25.25 0 0 0-.25-.25Z"/><path d="M5 8.75A.75.75 0 0 1 5.75 8h11.5a.75.75 0 0 1 0 1.5H5.75A.75.75 0 0 1 5 8.75Zm0 4a.75.75 0 0 1 .75-.75h5.5a.75.75 0 0 1 0 1.5h-5.5a.75.75 0 0 1-.75-.75Z"/></svg>');
}

/* experimental */
Expand Down Expand Up @@ -70,6 +71,25 @@
mask-image: var(--md-admonition-icon--learn);
}

/* message */
.md-typeset .admonition.message,
.md-typeset details.message {
border-color: rgb(0, 184, 212)
}

.md-typeset .message>.admonition-title,
.md-typeset .message>summary {
background-color: rgba(0, 184, 212, .1);
border-color: rgb(0, 184, 212);
}

.md-typeset .message>.admonition-title::before,
.md-typeset .message>summary::before {
background-color: rgb(0, 184, 212);
-webkit-mask-image: var(--md-admonition-icon--message);
mask-image: var(--md-admonition-icon--message);
}

/* badges */

.badge {
Expand Down
2 changes: 2 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ For general FAQ see [PSRule - Frequently Asked Questions (FAQ)][ps-rule-faq], in

!!! Note
If you have a question that is not answered here, please [join or start a discussion][discussion].
For common issues and workarounds, please see [troubleshooting][19].

[discussion]: https://github.com/Azure/PSRule.Rules.Azure/discussions
[13]: https://microsoft.github.io/PSRule/v2/faq/#how-do-exclude-or-ignore-files-from-being-processed
[14]: https://microsoft.github.io/PSRule/v2/faq/#how-do-i-disable-or-suppress-the-not-processed-warning
[19]: troubleshooting.md

## What is a rule?

Expand Down
4 changes: 2 additions & 2 deletions docs/setup/configuring-expansion.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ author: BernieWhite
PSRule for Azure can automatically resolve Azure resource context at runtime from infrastructure code.
This feature can be enabled by using the following configuration options.

## Configuration

!!! Tip
Each of these configuration options are set within the `ps-rule.yaml` file.
To learn how to set configuration options see [Configuring options][1].

[1]: configuring-options.md

## Available options

### Parameter file expansion

<!-- module:version v1.4.1 -->
Expand Down
135 changes: 135 additions & 0 deletions docs/setup/configuring-exports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
author: BernieWhite
---

# Configuring exports

For in-flight analysis or when using policy as rules data may be exported from one or more subscriptions.
To configure the export process see the following configuration options.

To use a configuration option, you **must** use the minimum version specified.
Earlier versions of PSRule for Azure will ignore the configuration option.

## General

### PSRULE_AZURE_RESOURCE_MODULE_NOWARN

<!-- module:version v1.38.0 -->

This configuration option suppresses a warning when the minimum version of `Az.Resources` module is not installed.
Unlike most options, this option can only set by environment variable.

Syntax:

```bash
PSRULE_AZURE_RESOURCE_MODULE_NOWARN: boolean
```

Default:

```bash
PSRULE_AZURE_RESOURCE_MODULE_NOWARN: false
```

Example:

=== "GitHub Actions"

```yaml
env:
PSRULE_AZURE_RESOURCE_MODULE_NOWARN: true
```

=== "Azure Pipelines"

```yaml
variables:
- name: PSRULE_AZURE_RESOURCE_MODULE_NOWARN
value: true
```

=== "PowerShell"

```powershell
$Env:PSRULE_AZURE_RESOURCE_MODULE_NOWARN = 'true'
```

=== "Bash"

```bash
export PSRULE_AZURE_RESOURCE_MODULE_NOWARN=true
```

## Policy as rules

The following configuration options apply when using policy as rules.

### AZURE_POLICY_IGNORE_LIST

<!-- module:version v1.21.0 -->

This configuration option configures a custom list policy definitions to ignore when exporting policy to rules.
In addition to the custom list, a built-in list of policies are ignored.
The built-in list can be found [here](https://github.com/Azure/PSRule.Rules.Azure/blob/main/data/policy-ignore.json).

Configure this option to ignore policy definitions that:

- Already have a rule defined.
- Are not relevant to testing Infrastructure as Code.

Syntax:

```yaml title="ps-rule.yaml"
configuration:
AZURE_POLICY_IGNORE_LIST: array
```
Default:
```yaml title="ps-rule.yaml"
# YAML: The default AZURE_POLICY_IGNORE_LIST configuration option
configuration:
AZURE_POLICY_IGNORE_LIST: []
```
Example:
```yaml title="ps-rule.yaml"
# YAML: Add custom policy definitions to ignore
configuration:
AZURE_POLICY_IGNORE_LIST:
- '/providers/Microsoft.Authorization/policyDefinitions/1f314764-cb73-4fc9-b863-8eca98ac36e9'
- '/providers/Microsoft.Authorization/policyDefinitions/b54ed75b-3e1a-44ac-a333-05ba39b99ff0'
```
### AZURE_POLICY_RULE_PREFIX
<!-- module:version v1.20.0 -->
This configuration option sets the prefix for names of exported rules.
Configure this option to change the prefix, which defaults to `Azure`.

This configuration option will be ignored when `-Prefix` is used with `Export-AzPolicyAssignmentRuleData`.

Syntax:

```yaml title="ps-rule.yaml"
configuration:
AZURE_POLICY_RULE_PREFIX: string
```

Default:

```yaml title="ps-rule.yaml"
# YAML: The default AZURE_POLICY_RULE_PREFIX configuration option
configuration:
AZURE_POLICY_RULE_PREFIX: Azure
```

Example:

```yaml title="ps-rule.yaml"
# YAML: Override the prefix of exported policy rules
configuration:
AZURE_POLICY_RULE_PREFIX: AzureCustomPrefix
```
72 changes: 3 additions & 69 deletions docs/setup/configuring-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Earlier versions of PSRule for Azure will ignore the configuration option.
Each of these configuration options are set within the `ps-rule.yaml` file.
To learn how to set configuration options see [Configuring options][1].

[1]: configuring-options.md
[1]: index.md

## Available options

### AZURE_AKS_CLUSTER_MINIMUM_SYSTEM_NODES

Expand Down Expand Up @@ -605,74 +607,6 @@ configuration:
- 'anotherLinuxOffer'
```

### AZURE_POLICY_IGNORE_LIST

<!-- module:version v1.21.0 -->

This configuration option configures a custom list policy definitions to ignore when exporting policy to rules.
In addition to the custom list, a built-in list of policies are ignored.
The built-in list can be found [here](https://github.com/Azure/PSRule.Rules.Azure/blob/main/data/policy-ignore.json).

Configure this option to ignore policy definitions that:

- Already have a rule defined.
- Are not relevant to testing Infrastructure as Code.

Syntax:

```yaml title="ps-rule.yaml"
configuration:
AZURE_POLICY_IGNORE_LIST: array
```

Default:

```yaml title="ps-rule.yaml"
# YAML: The default AZURE_POLICY_IGNORE_LIST configuration option
configuration:
AZURE_POLICY_IGNORE_LIST: []
```

Example:

```yaml title="ps-rule.yaml"
# YAML: Add a custom policy definition to ignore
AZURE_POLICY_IGNORE_LIST:
- '/providers/Microsoft.Authorization/policyDefinitions/1f314764-cb73-4fc9-b863-8eca98ac36e9'
- '/providers/Microsoft.Authorization/policyDefinitions/b54ed75b-3e1a-44ac-a333-05ba39b99ff0'
```

### AZURE_POLICY_RULE_PREFIX

<!-- module:version v1.20.0 -->

This configuration option sets the prefix for names of exported rules.
Configure this option to change the prefix, which defaults to `Azure`.

This configuration option will be ignored when `-Prefix` is used with `Export-AzPolicyAssignmentRuleData`.

Syntax:

```yaml title="ps-rule.yaml"
configuration:
AZURE_POLICY_RULE_PREFIX: string
```

Default:

```yaml title="ps-rule.yaml"
# YAML: The default AZURE_POLICY_RULE_PREFIX configuration option
configuration:
AZURE_POLICY_RULE_PREFIX: Azure
```

Example:

```yaml title="ps-rule.yaml"
# YAML: Override the prefix of exported policy rules
AZURE_POLICY_RULE_PREFIX: AzureCustomPrefix
```

### AZURE_POLICY_WAIVER_MAX_EXPIRY

<!-- module:version v1.3.0 -->
Expand Down
12 changes: 10 additions & 2 deletions docs/setup/configuring-options.md → docs/setup/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ PSRule for Azure comes with many configuration options.
Additionally, the PSRule engine includes several options that apply to all rules.
You can visit the [about_PSRule_Options][1] topic to read about general PSRule options.

!!! Abstract
This topic covers the basics of configuration options.
A list of configuration options is available for:

- [Configuring rule defaults](configuring-rules.md)
- [Configuring expansion](configuring-expansion.md)
- [Configuring exports](configuring-exports.md)

[1]: https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Options/

## Setting options
## Setting options in YAML

Configuration options are set within the `ps-rule.yaml` file.
PSRule will automatically find this file within the current working directory.
Expand Down Expand Up @@ -49,7 +57,7 @@ Use comments to add context.
AZURE_BICEP_CHECK_TOOL: true

# Optionally, configure the minimum version of the Bicep CLI.
AZURE_BICEP_MINIMUM_VERSION: '0.16.2'
AZURE_BICEP_MINIMUM_VERSION: '0.28.1'

# Configure the minimum AKS cluster version.
AZURE_AKS_CLUSTER_MINIMUM_VERSION: '1.28.9'
Expand Down
Loading

0 comments on commit 149c0aa

Please sign in to comment.