Skip to content

Commit

Permalink
resolve some comments from other DC reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo committed Feb 23, 2021
1 parent a35b495 commit 08722d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ func resourceSentinelDataConnectorAwsCloudTrailCreateUpdate(d *schema.ResourceDa
resp, err := client.Get(ctx, id.ResourceGroup, operationalInsightsResourceProvider, id.WorkspaceName, name)
if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("checking for existing Sentinel Data Connector AWS Cloud Trail %q: %+v", id, err)
return fmt.Errorf("checking for existing %s: %+v", id, err)
}
}

id := dataConnectorID(resp.Value)
if id != nil && *id != "" {
return tf.ImportAsExistsError("azurerm_sentinel_data_connector_aws_cloud_trail", *id)
}
return tf.ImportAsExistsError("azurerm_sentinel_data_connector_aws_cloud_trail", id.ID())
}

param := securityinsight.AwsCloudTrailDataConnector{
Expand All @@ -104,18 +101,18 @@ func resourceSentinelDataConnectorAwsCloudTrailCreateUpdate(d *schema.ResourceDa
if !d.IsNewResource() {
resp, err := client.Get(ctx, id.ResourceGroup, operationalInsightsResourceProvider, id.WorkspaceName, name)
if err != nil {
return fmt.Errorf("retrieving Sentinel Data Connector AWS Cloud Trail %q: %+v", id, err)
return fmt.Errorf("retrieving %s: %+v", id, err)
}

if err := assertDataConnectorKind(resp.Value, securityinsight.DataConnectorKindAmazonWebServicesCloudTrail); err != nil {
return fmt.Errorf("asserting Sentinel Data Connector of %q: %+v", id, err)
return fmt.Errorf("asserting %s: %+v", id, err)
}
param.Etag = resp.Value.(securityinsight.AwsCloudTrailDataConnector).Etag
}

_, err = client.CreateOrUpdate(ctx, id.ResourceGroup, operationalInsightsResourceProvider, id.WorkspaceName, id.Name, param)
if err != nil {
return fmt.Errorf("creating Sentinel Data Connector AWS Cloud Trail %q: %+v", id, err)
return fmt.Errorf("creating %s: %+v", id, err)
}

d.SetId(id.ID())
Expand All @@ -137,16 +134,16 @@ func resourceSentinelDataConnectorAwsCloudTrailRead(d *schema.ResourceData, meta
resp, err := client.Get(ctx, id.ResourceGroup, operationalInsightsResourceProvider, id.WorkspaceName, id.Name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Sentinel Data Connector AWS Cloud Trail %q was not found - removing from state!", id)
log.Printf("[DEBUG] %s was not found - removing from state!", id)
d.SetId("")
return nil
}

return fmt.Errorf("retrieving Sentinel Data Connector AWS Cloud Trail %q: %+v", id, err)
return fmt.Errorf("retrieving %s: %+v", id, err)
}

if err := assertDataConnectorKind(resp.Value, securityinsight.DataConnectorKindAmazonWebServicesCloudTrail); err != nil {
return fmt.Errorf("asserting Sentinel Data Connector AWS Cloud Trail of %q: %+v", id, err)
return fmt.Errorf("asserting %s: %+v", id, err)
}
dc := resp.Value.(securityinsight.AwsCloudTrailDataConnector)

Expand All @@ -171,7 +168,7 @@ func resourceSentinelDataConnectorAwsCloudTrailDelete(d *schema.ResourceData, me

_, err = client.Delete(ctx, id.ResourceGroup, operationalInsightsResourceProvider, id.WorkspaceName, id.Name)
if err != nil {
return fmt.Errorf("deleting Sentinel Data Connector AWS Cloud Trail %q: %+v", id, err)
return fmt.Errorf("deleting %s: %+v", id, err)
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ resource "azurerm_sentinel_data_connector_aws_cloud_trail" "example" {

The following arguments are supported:

- `aws_role_arn` - (Required) The ARN of the AWS CloudTrail role, which is connected to this AWS CloudTrail Data Connector.
* `aws_role_arn` - (Required) The ARN of the AWS CloudTrail role, which is connected to this AWS CloudTrail Data Connector.

- `log_analytics_workspace_id` - (Required) The ID of the Log Analytics Workspace that this AWS CloudTrail Data Connector resides in. Changing this forces a new AWS CloudTrail Data Connector to be created.
* `log_analytics_workspace_id` - (Required) The ID of the Log Analytics Workspace that this AWS CloudTrail Data Connector resides in. Changing this forces a new AWS CloudTrail Data Connector to be created.

- `name` - (Required) The name which should be used for this AWS CloudTrail Data Connector. Changing this forces a new AWS CloudTrail Data Connector to be created.
* `name` - (Required) The name which should be used for this AWS CloudTrail Data Connector. Changing this forces a new AWS CloudTrail Data Connector to be created.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

- `id` - The ID of the AWS CloudTrail Data Connector.
* `id` - The ID of the AWS CloudTrail Data Connector.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:

- `create` - (Defaults to 30 minutes) Used when creating the AWS CloudTrail Data Connector.
- `read` - (Defaults to 5 minutes) Used when retrieving the AWS CloudTrail Data Connector.
- `update` - (Defaults to 30 minutes) Used when updating the AWS CloudTrail Data Connector.
- `delete` - (Defaults to 30 minutes) Used when deleting the AWS CloudTrail Data Connector.
* `create` - (Defaults to 30 minutes) Used when creating the AWS CloudTrail Data Connector.
* `read` - (Defaults to 5 minutes) Used when retrieving the AWS CloudTrail Data Connector.
* `update` - (Defaults to 30 minutes) Used when updating the AWS CloudTrail Data Connector.
* `delete` - (Defaults to 30 minutes) Used when deleting the AWS CloudTrail Data Connector.

## Import

Expand Down

0 comments on commit 08722d2

Please sign in to comment.