Skip to content

Commit

Permalink
Merge pull request #29769 from pschun/f-ssmincidents-replicationset
Browse files Browse the repository at this point in the history
New Resource and Data source: aws_ssmincidents_replicationset
  • Loading branch information
ewbankkit authored Mar 28, 2023
2 parents eba8a7b + 4deaa45 commit 61b0c8f
Show file tree
Hide file tree
Showing 20 changed files with 1,733 additions and 86 deletions.
7 changes: 7 additions & 0 deletions .changelog/29769.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
aws_ssmincidents_replication_set
```

```release-note:new-data-source
aws_ssmincidents_replication_set
```
14 changes: 14 additions & 0 deletions .ci/.semgrep-service-name0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3260,3 +3260,17 @@ rules:
patterns:
- pattern-regex: "(?i)ConfigService"
severity: WARNING
- id: configservice-in-var-name
languages:
- go
message: Do not use "ConfigService" in var name inside configservice package
paths:
include:
- internal/service/configservice
patterns:
- pattern: var $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)ConfigService"
severity: WARNING
43 changes: 29 additions & 14 deletions .ci/.semgrep-service-name1.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT.
rules:
- id: configservice-in-var-name
languages:
- go
message: Do not use "ConfigService" in var name inside configservice package
paths:
include:
- internal/service/configservice
patterns:
- pattern: var $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)ConfigService"
severity: WARNING
- id: connect-in-func-name
languages:
- go
Expand Down Expand Up @@ -3249,3 +3235,32 @@ rules:
- pattern-regex: "(?i)Inspector2"
- pattern-not-regex: ^TestAcc.*
severity: WARNING
- id: inspector2-in-test-name
languages:
- go
message: Include "Inspector2" in test name
paths:
include:
- internal/service/inspector2/*_test.go
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-not-regex: "^TestAccInspector2"
- pattern-regex: ^TestAcc.*
severity: WARNING
- id: inspector2-in-const-name
languages:
- go
message: Do not use "Inspector2" in const name inside inspector2 package
paths:
include:
- internal/service/inspector2
patterns:
- pattern: const $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)Inspector2"
severity: WARNING
72 changes: 43 additions & 29 deletions .ci/.semgrep-service-name2.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
# Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT.
rules:
- id: inspector2-in-test-name
languages:
- go
message: Include "Inspector2" in test name
paths:
include:
- internal/service/inspector2/*_test.go
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-not-regex: "^TestAccInspector2"
- pattern-regex: ^TestAcc.*
severity: WARNING
- id: inspector2-in-const-name
languages:
- go
message: Do not use "Inspector2" in const name inside inspector2 package
paths:
include:
- internal/service/inspector2
patterns:
- pattern: const $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)Inspector2"
severity: WARNING
- id: inspector2-in-var-name
languages:
- go
Expand Down Expand Up @@ -3245,3 +3216,46 @@ rules:
- pattern-not-regex: "^TestAccRDS"
- pattern-regex: ^TestAcc.*
severity: WARNING
- id: rds-in-const-name
languages:
- go
message: Do not use "RDS" in const name inside rds package
paths:
include:
- internal/service/rds
patterns:
- pattern: const $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)RDS"
severity: WARNING
- id: rds-in-var-name
languages:
- go
message: Do not use "RDS" in var name inside rds package
paths:
include:
- internal/service/rds
patterns:
- pattern: var $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)RDS"
severity: WARNING
- id: redshift-in-func-name
languages:
- go
message: Do not use "Redshift" in func name inside redshift package
paths:
include:
- internal/service/redshift
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)Redshift"
- pattern-not-regex: ^TestAcc.*
severity: WARNING
101 changes: 58 additions & 43 deletions .ci/.semgrep-service-name3.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
# Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT.
rules:
- id: rds-in-const-name
languages:
- go
message: Do not use "RDS" in const name inside rds package
paths:
include:
- internal/service/rds
patterns:
- pattern: const $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)RDS"
severity: WARNING
- id: rds-in-var-name
languages:
- go
message: Do not use "RDS" in var name inside rds package
paths:
include:
- internal/service/rds
patterns:
- pattern: var $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)RDS"
severity: WARNING
- id: redshift-in-func-name
languages:
- go
message: Do not use "Redshift" in func name inside redshift package
paths:
include:
- internal/service/redshift
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)Redshift"
- pattern-not-regex: ^TestAcc.*
severity: WARNING
- id: redshift-in-test-name
languages:
- go
Expand Down Expand Up @@ -2260,6 +2217,64 @@ rules:
patterns:
- pattern-regex: "(?i)SSM"
severity: WARNING
- id: ssmincidents-in-func-name
languages:
- go
message: Do not use "SSMIncidents" in func name inside ssmincidents package
paths:
include:
- internal/service/ssmincidents
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)SSMIncidents"
- pattern-not-regex: ^TestAcc.*
severity: WARNING
- id: ssmincidents-in-test-name
languages:
- go
message: Include "SSMIncidents" in test name
paths:
include:
- internal/service/ssmincidents/*_test.go
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-not-regex: "^TestAccSSMIncidents"
- pattern-regex: ^TestAcc.*
severity: WARNING
- id: ssmincidents-in-const-name
languages:
- go
message: Do not use "SSMIncidents" in const name inside ssmincidents package
paths:
include:
- internal/service/ssmincidents
patterns:
- pattern: const $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)SSMIncidents"
severity: WARNING
- id: ssmincidents-in-var-name
languages:
- go
message: Do not use "SSMIncidents" in var name inside ssmincidents package
paths:
include:
- internal/service/ssmincidents
patterns:
- pattern: var $NAME = ...
- metavariable-pattern:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)SSMIncidents"
severity: WARNING
- id: ssoadmin-in-func-name
languages:
- go
Expand Down
1 change: 1 addition & 0 deletions .teamcity/components/generated/services_all.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ val services = mapOf(
"sns" to ServiceSpec("SNS (Simple Notification)"),
"sqs" to ServiceSpec("SQS (Simple Queue)"),
"ssm" to ServiceSpec("SSM (Systems Manager)", vpcLock = true),
"ssmincidents" to ServiceSpec("SSM Incident Manager Incidents"),
"ssoadmin" to ServiceSpec("SSO Admin"),
"storagegateway" to ServiceSpec("Storage Gateway", vpcLock = true),
"sts" to ServiceSpec("STS (Security Token)"),
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/service_packages_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions internal/service/ssmincidents/find.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ssmincidents

import (
"context"
"errors"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ssmincidents"
"github.com/aws/aws-sdk-go-v2/service/ssmincidents/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

func FindReplicationSetByID(context context.Context, client *ssmincidents.Client, arn string) (*types.ReplicationSet, error) {
input := &ssmincidents.GetReplicationSetInput{
Arn: aws.String(arn),
}
output, err := client.GetReplicationSet(context, input)
if err != nil {
var notFoundError *types.ResourceNotFoundException
if errors.As(err, &notFoundError) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
}
}

return nil, err
}

if output == nil || output.ReplicationSet == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.ReplicationSet, nil
}
50 changes: 50 additions & 0 deletions internal/service/ssmincidents/flex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ssmincidents

import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ssmincidents/types"
)

func expandRegions(regions []interface{}) map[string]types.RegionMapInputValue {
if len(regions) == 0 {
return nil
}

regionMap := make(map[string]types.RegionMapInputValue)
for _, region := range regions {
regionData := region.(map[string]interface{})

input := types.RegionMapInputValue{}

if kmsKey := regionData["kms_key_arn"].(string); kmsKey != "DefaultKey" {
input.SseKmsKeyId = aws.String(kmsKey)
}

regionMap[regionData["name"].(string)] = input
}

return regionMap
}

func flattenRegions(regions map[string]types.RegionInfo) []map[string]interface{} {
if len(regions) == 0 {
return nil
}

tfRegionData := make([]map[string]interface{}, 0)
for regionName, regionData := range regions {
region := make(map[string]interface{})

region["name"] = regionName
region["status"] = regionData.Status
region["kms_key_arn"] = aws.ToString(regionData.SseKmsKeyId)

if v := regionData.StatusMessage; v != nil {
region["status_message"] = aws.ToString(v)
}

tfRegionData = append(tfRegionData, region)
}

return tfRegionData
}
Loading

0 comments on commit 61b0c8f

Please sign in to comment.