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

Add table azure_policy_assignment. Closes #122 #123

Merged
merged 16 commits into from
May 17, 2021
Merged

Add table azure_policy_assignment. Closes #122 #123

merged 16 commits into from
May 17, 2021

Conversation

bigdatasourav
Copy link
Contributor

Integration test logs

Logs
SETUP: tests/azure_policy_assignment []

PRETEST: tests/azure_policy_assignment

TEST: tests/azure_policy_assignment
Running terraform
azurerm_policy_definition.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creation complete after 5s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest38478]
azurerm_policy_definition.named_test_resource: Still creating... [10s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [20s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [30s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [40s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [50s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [1m0s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [1m10s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [1m20s elapsed]
azurerm_policy_definition.named_test_resource: Still creating... [1m30s elapsed]
azurerm_policy_definition.named_test_resource: Creation complete after 1m34s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyDefinitions/SecurityCenterBuiltIn]
azurerm_policy_assignment.named_test_resource: Creating...
azurerm_policy_assignment.named_test_resource: Still creating... [10s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [20s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [30s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [40s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [50s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [1m0s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [1m10s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [1m20s elapsed]
azurerm_policy_assignment.named_test_resource: Still creating... [1m30s elapsed]
azurerm_policy_assignment.named_test_resource: Creation complete after 1m33s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest38478/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


Warning: Version constraints inside provider configuration blocks are deprecated

  on variables.tf line 22, in provider "azurerm":
  22:   version = "=2.43.0"

Terraform 0.13 and earlier allowed provider version constraints inside the
provider configuration block, but that is now deprecated and will be removed
in a future version of Terraform. To silence this warning, move the provider
version constraint into the required_providers block.


Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Outputs:

resource_aka = "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn"
resource_aka_lower = "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/microsoft.authorization/policyassignments/securitycenterbuiltin"
resource_id = "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn"
resource_name = "SecurityCenterBuiltIn"
subscription_id = "d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8"

Running SQL query: test-get-query.sql
[
  {
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn",
    "name": "SecurityCenterBuiltIn",
    "type": "Microsoft.Authorization/policyAssignments"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn",
    "name": "SecurityCenterBuiltIn",
    "type": "Microsoft.Authorization/policyAssignments"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn",
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/microsoft.authorization/policyassignments/securitycenterbuiltin"
    ],
    "name": "SecurityCenterBuiltIn",
    "title": "SecurityCenterBuiltIn"
  }
]
✔ PASSED

POSTTEST: tests/azure_policy_assignment

TEARDOWN: tests/azure_policy_assignment

SUMMARY:

1/1 passed.


Example query results

Results
> select
  id,
  name,
  type
from
  azure_policy_assignment;
+-------------------------------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------+
| id                                                                                                                            | name                  | type                                      |
+-------------------------------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------+
| /subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn | SecurityCenterBuiltIn | Microsoft.Authorization/policyAssignments |
+-------------------------------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------+

@bigdatasourav bigdatasourav self-assigned this May 7, 2021
@bigdatasourav bigdatasourav linked an issue May 7, 2021 that may be closed by this pull request
Copy link
Contributor

@LalitLab LalitLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigdatasourav left few comments

azure/table_azure_policy_assignment.go Outdated Show resolved Hide resolved
@cbruno10 cbruno10 removed the request for review from Subhajit97 May 11, 2021 12:56
Comment on lines 44 to 84
{
Name: "policy_definition_id",
Description: "The ID of the policy definition or policy set definition being assigned.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("AssignmentProperties.PolicyDefinitionID"),
},
{
Name: "scope",
Description: "The scope for the policy assignment.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("AssignmentProperties.Scope"),
},
{
Name: "type",
Description: "The type of the policy assignment.",
Type: proto.ColumnType_STRING,
},
{
Name: "sku_name",
Description: "The name of the policy sku.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Sku.Name"),
},
{
Name: "sku_tier",
Description: "The policy sku tier.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Sku.Tier").Transform(transform.ToString),
},
{
Name: "enforcement_mode",
Description: "The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("AssignmentProperties.EnforcementMode"),
},
{
Name: "description",
Description: "This message will be part of response in case of policy violation.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("AssignmentProperties.Description"),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort columns in alphabetical order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

till policy_definition_id , kept it as the important Key columns after that sorted. should it any other different order ?

Copy link
Contributor

@LalitLab LalitLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@rajlearner17 rajlearner17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbruno10 cbruno10 merged commit 7bb4bf3 into main May 17, 2021
@cbruno10 cbruno10 deleted the issue-122 branch May 17, 2021 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add table azure_policy_assignment
4 participants