diff --git a/.ci/.semgrep-service-name0.yml b/.ci/.semgrep-service-name0.yml index 768e44b5830..0bccb83cb88 100644 --- a/.ci/.semgrep-service-name0.yml +++ b/.ci/.semgrep-service-name0.yml @@ -3187,3 +3187,18 @@ rules: - pattern-not-regex: .*uickConnect.* - pattern-not-regex: ^TestAcc.* severity: WARNING + - id: connect-in-test-name + languages: + - go + message: Include "Connect" in test name + paths: + include: + - internal/service/connect/*_test.go + patterns: + - pattern: func $NAME( ... ) { ... } + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-not-regex: "^TestAccConnect" + - pattern-regex: ^TestAcc.* + severity: WARNING diff --git a/.ci/.semgrep-service-name1.yml b/.ci/.semgrep-service-name1.yml index 116b28ecea2..683f2ebbdd4 100644 --- a/.ci/.semgrep-service-name1.yml +++ b/.ci/.semgrep-service-name1.yml @@ -1,20 +1,5 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: - - id: connect-in-test-name - languages: - - go - message: Include "Connect" in test name - paths: - include: - - internal/service/connect/*_test.go - patterns: - - pattern: func $NAME( ... ) { ... } - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-not-regex: "^TestAccConnect" - - pattern-regex: ^TestAcc.* - severity: WARNING - id: connect-in-const-name languages: - go @@ -3176,3 +3161,31 @@ rules: - 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 + message: Do not use "Inspector2" in var name inside inspector2 package + paths: + include: + - internal/service/inspector2 + patterns: + - pattern: var $NAME = ... + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)Inspector2" + severity: WARNING diff --git a/.ci/.semgrep-service-name2.yml b/.ci/.semgrep-service-name2.yml index 79e6b8f6971..4d634bbadfd 100644 --- a/.ci/.semgrep-service-name2.yml +++ b/.ci/.semgrep-service-name2.yml @@ -1,33 +1,5 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: - - 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 - message: Do not use "Inspector2" in var name inside inspector2 package - paths: - include: - - internal/service/inspector2 - patterns: - - pattern: var $NAME = ... - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)Inspector2" - severity: WARNING - id: inspectorv2-in-func-name languages: - go @@ -2432,6 +2404,64 @@ rules: patterns: - pattern-regex: "(?i)OpenSearch" severity: WARNING + - id: opensearchserverless-in-func-name + languages: + - go + message: Do not use "OpenSearchServerless" in func name inside opensearchserverless package + paths: + include: + - internal/service/opensearchserverless + patterns: + - pattern: func $NAME( ... ) { ... } + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)OpenSearchServerless" + - pattern-not-regex: ^TestAcc.* + severity: WARNING + - id: opensearchserverless-in-test-name + languages: + - go + message: Include "OpenSearchServerless" in test name + paths: + include: + - internal/service/opensearchserverless/*_test.go + patterns: + - pattern: func $NAME( ... ) { ... } + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-not-regex: "^TestAccOpenSearchServerless" + - pattern-regex: ^TestAcc.* + severity: WARNING + - id: opensearchserverless-in-const-name + languages: + - go + message: Do not use "OpenSearchServerless" in const name inside opensearchserverless package + paths: + include: + - internal/service/opensearchserverless + patterns: + - pattern: const $NAME = ... + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)OpenSearchServerless" + severity: WARNING + - id: opensearchserverless-in-var-name + languages: + - go + message: Do not use "OpenSearchServerless" in var name inside opensearchserverless package + paths: + include: + - internal/service/opensearchserverless + patterns: + - pattern: var $NAME = ... + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)OpenSearchServerless" + severity: WARNING - id: opensearchservice-in-func-name languages: - go @@ -3156,18 +3186,3 @@ rules: - pattern-regex: "(?i)Redshift" - pattern-not-regex: ^TestAcc.* severity: WARNING - - id: redshift-in-test-name - languages: - - go - message: Include "Redshift" in test name - paths: - include: - - internal/service/redshift/*_test.go - patterns: - - pattern: func $NAME( ... ) { ... } - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-not-regex: "^TestAccRedshift" - - pattern-regex: ^TestAcc.* - severity: WARNING diff --git a/.ci/.semgrep-service-name3.yml b/.ci/.semgrep-service-name3.yml index ecd2cc5f082..ac1731ee52e 100644 --- a/.ci/.semgrep-service-name3.yml +++ b/.ci/.semgrep-service-name3.yml @@ -1,5 +1,20 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: + - id: redshift-in-test-name + languages: + - go + message: Include "Redshift" in test name + paths: + include: + - internal/service/redshift/*_test.go + patterns: + - pattern: func $NAME( ... ) { ... } + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-not-regex: "^TestAccRedshift" + - pattern-regex: ^TestAcc.* + severity: WARNING - id: redshift-in-const-name languages: - go diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 9d24e46c8aa..8d0d4d272a5 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -449,6 +449,8 @@ service/nimble: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_nimble_' service/opensearch: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_opensearch_' +service/opensearchserverless: + - '((\*|-)\s*`?|(data|resource)\s+"?)aws_opensearchserverless_' service/opsworks: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_opsworks_' service/opsworkscm: diff --git a/.github/labeler-pr-triage.yml b/.github/labeler-pr-triage.yml index 47aae6b4c9f..bb21dd378b9 100644 --- a/.github/labeler-pr-triage.yml +++ b/.github/labeler-pr-triage.yml @@ -736,6 +736,9 @@ service/nimble: service/opensearch: - 'internal/service/opensearch/**/*' - 'website/**/opensearch_*' +service/opensearchserverless: + - 'internal/service/opensearchserverless/**/*' + - 'website/**/opensearchserverless_*' service/opsworks: - 'internal/service/opsworks/**/*' - 'website/**/opsworks_*' diff --git a/.teamcity/components/generated/services_all.kt b/.teamcity/components/generated/services_all.kt index 14dcf845504..cc836f1c2df 100644 --- a/.teamcity/components/generated/services_all.kt +++ b/.teamcity/components/generated/services_all.kt @@ -127,6 +127,7 @@ val services = mapOf( "networkfirewall" to ServiceSpec("Network Firewall", vpcLock = true), "networkmanager" to ServiceSpec("Network Manager"), "opensearch" to ServiceSpec("OpenSearch"), + "opensearchserverless" to ServiceSpec("OpenSearch Serverless"), "opsworks" to ServiceSpec("OpsWorks", vpcLock = true), "organizations" to ServiceSpec("Organizations"), "outposts" to ServiceSpec("Outposts"), diff --git a/go.mod b/go.mod index 359c732d41e..2a96bded9ad 100644 --- a/go.mod +++ b/go.mod @@ -80,6 +80,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/iam v1.18.4 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.20 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.20 // indirect + github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.0.2 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.11.4 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.16.4 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect diff --git a/go.sum b/go.sum index 13cff7cc75c..669ed85fd3f 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/aws/aws-sdk-go-v2/service/kendra v1.36.1 h1:kkzPhuVpcuz7N7910XGgnczYd github.com/aws/aws-sdk-go-v2/service/kendra v1.36.1/go.mod h1:EazC06zRCDZjeYInlIURLpvGsqURkYT24vCm7dbuL5A= github.com/aws/aws-sdk-go-v2/service/medialive v1.26.0 h1:efAz2VZcBg1YG5evAq1vzS6fij5I8knb5q3w6sKSJbQ= github.com/aws/aws-sdk-go-v2/service/medialive v1.26.0/go.mod h1:3wXEWmABxeDt9FqiMCjGqr+/eNjhbRqTLO3LHg+Z814= +github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.0.2 h1:bcn8Z+cB86OGQbJGheFywFieMDAVY7mKxH369HvnMmU= +github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.0.2/go.mod h1:r1aTV/abw3nJTZQgpKQv1wb3tTX+LahVRYULEh+WNRI= github.com/aws/aws-sdk-go-v2/service/pipes v1.0.1 h1:fnoi3/dnqmgq4NEG6h8OZf6gPE0QVsNAMyDrdNHvuT4= github.com/aws/aws-sdk-go-v2/service/pipes v1.0.1/go.mod h1:v7oTSuRooh6pHa3YitvBTCzwCch8cfdKI0sg/FVKwyo= github.com/aws/aws-sdk-go-v2/service/rds v1.35.0 h1:S583sAvE4bAtZYJyDWwSmcx2TG093Kreum+uIQ7V8ic= diff --git a/infrastructure/repository/labels-service.tf b/infrastructure/repository/labels-service.tf index 817e755a73e..9d7a1c9fa58 100644 --- a/infrastructure/repository/labels-service.tf +++ b/infrastructure/repository/labels-service.tf @@ -212,6 +212,7 @@ variable "service_labels" { "networkmanager", "nimble", "opensearch", + "opensearchserverless", "opsworks", "opsworkscm", "organizations", diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index 90fc18924fd..171831fc80c 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ivschat" "github.com/aws/aws-sdk-go-v2/service/kendra" "github.com/aws/aws-sdk-go-v2/service/medialive" + "github.com/aws/aws-sdk-go-v2/service/opensearchserverless" "github.com/aws/aws-sdk-go-v2/service/pipes" rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/resourceexplorer2" @@ -546,6 +547,7 @@ type AWSClient struct { NetworkManagerConn *networkmanager.NetworkManager NimbleConn *nimblestudio.NimbleStudio OpenSearchConn *opensearchservice.OpenSearchService + OpenSearchServerlessClient *opensearchserverless.Client OpsWorksConn *opsworks.OpsWorks OpsWorksCMConn *opsworkscm.OpsWorksCM OrganizationsConn *organizations.Organizations diff --git a/internal/conns/config_gen.go b/internal/conns/config_gen.go index 7a847e78733..461b2a4de07 100644 --- a/internal/conns/config_gen.go +++ b/internal/conns/config_gen.go @@ -15,6 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ivschat" "github.com/aws/aws-sdk-go-v2/service/kendra" "github.com/aws/aws-sdk-go-v2/service/medialive" + "github.com/aws/aws-sdk-go-v2/service/opensearchserverless" "github.com/aws/aws-sdk-go-v2/service/pipes" rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/resourceexplorer2" @@ -650,6 +651,11 @@ func (c *Config) sdkv2Conns(client *AWSClient, cfg aws_sdkv2.Config) { o.EndpointResolver = medialive.EndpointResolverFromURL(endpoint) } }) + client.OpenSearchServerlessClient = opensearchserverless.NewFromConfig(cfg, func(o *opensearchserverless.Options) { + if endpoint := c.Endpoints[names.OpenSearchServerless]; endpoint != "" { + o.EndpointResolver = opensearchserverless.EndpointResolverFromURL(endpoint) + } + }) client.PipesClient = pipes.NewFromConfig(cfg, func(o *pipes.Options) { if endpoint := c.Endpoints[names.Pipes]; endpoint != "" { o.EndpointResolver = pipes.EndpointResolverFromURL(endpoint) diff --git a/internal/service/opensearchserverless/generate.go b/internal/service/opensearchserverless/generate.go new file mode 100644 index 00000000000..85c63ca0676 --- /dev/null +++ b/internal/service/opensearchserverless/generate.go @@ -0,0 +1,4 @@ +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ServiceTagsSlice -UpdateTags +// ONLY generate directives and package declaration! Do not add anything else to this file. + +package opensearchserverless diff --git a/internal/service/opensearchserverless/tags_gen.go b/internal/service/opensearchserverless/tags_gen.go new file mode 100644 index 00000000000..493be81931b --- /dev/null +++ b/internal/service/opensearchserverless/tags_gen.go @@ -0,0 +1,94 @@ +// Code generated by internal/generate/tags/main.go; DO NOT EDIT. +package opensearchserverless + +import ( + "context" + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/opensearchserverless" + "github.com/aws/aws-sdk-go-v2/service/opensearchserverless/types" + tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" +) + +// ListTags lists opensearchserverless service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func ListTags(ctx context.Context, conn *opensearchserverless.Client, identifier string) (tftags.KeyValueTags, error) { + input := &opensearchserverless.ListTagsForResourceInput{ + ResourceArn: aws.String(identifier), + } + + output, err := conn.ListTagsForResource(ctx, input) + + if err != nil { + return tftags.New(nil), err + } + + return KeyValueTags(output.Tags), nil +} + +// []*SERVICE.Tag handling + +// Tags returns opensearchserverless service tags. +func Tags(tags tftags.KeyValueTags) []types.Tag { + result := make([]types.Tag, 0, len(tags)) + + for k, v := range tags.Map() { + tag := types.Tag{ + Key: aws.String(k), + Value: aws.String(v), + } + + result = append(result, tag) + } + + return result +} + +// KeyValueTags creates tftags.KeyValueTags from opensearchserverless service tags. +func KeyValueTags(tags []types.Tag) tftags.KeyValueTags { + m := make(map[string]*string, len(tags)) + + for _, tag := range tags { + m[aws.ToString(tag.Key)] = tag.Value + } + + return tftags.New(m) +} + +// UpdateTags updates opensearchserverless service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func UpdateTags(ctx context.Context, conn *opensearchserverless.Client, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := tftags.New(oldTagsMap) + newTags := tftags.New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &opensearchserverless.UntagResourceInput{ + ResourceArn: aws.String(identifier), + TagKeys: removedTags.IgnoreAWS().Keys(), + } + + _, err := conn.UntagResource(ctx, input) + + if err != nil { + return fmt.Errorf("untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &opensearchserverless.TagResourceInput{ + ResourceArn: aws.String(identifier), + Tags: Tags(updatedTags.IgnoreAWS()), + } + + _, err := conn.TagResource(ctx, input) + + if err != nil { + return fmt.Errorf("tagging resource (%s): %w", identifier, err) + } + } + + return nil +} diff --git a/names/consts_gen.go b/names/consts_gen.go index 85d3d1b9fbe..8c212e23d1f 100644 --- a/names/consts_gen.go +++ b/names/consts_gen.go @@ -209,6 +209,7 @@ const ( NetworkManager = "networkmanager" Nimble = "nimble" OpenSearch = "opensearch" + OpenSearchServerless = "opensearchserverless" OpsWorks = "opsworks" OpsWorksCM = "opsworkscm" Organizations = "organizations" diff --git a/names/names.go b/names/names.go index 33f67219120..0b074d70ef4 100644 --- a/names/names.go +++ b/names/names.go @@ -23,23 +23,24 @@ import ( // This "should" be defined by the AWS Go SDK v2, but currently isn't. const ( - AuditManagerEndpointID = "auditmanager" - CloudWatchLogsEndpointID = "logs" - ComprehendEndpointID = "comprehend" - ComputeOptimizerEndpointID = "computeoptimizer" - IdentityStoreEndpointID = "identitystore" - Inspector2EndpointID = "inspector2" - IVSChatEndpointID = "ivschat" - KendraEndpointID = "kendra" - MediaLiveEndpointID = "medialive" - PipesEndpointID = "pipes" - ResourceExplorer2EndpointID = "resource-explorer-2" - RolesAnywhereEndpointID = "rolesanywhere" - Route53DomainsEndpointID = "route53domains" - SchedulerEndpointID = "scheduler" - SESV2EndpointID = "sesv2" - SSMEndpointID = "ssm" - TranscribeEndpointID = "transcribe" + AuditManagerEndpointID = "auditmanager" + CloudWatchLogsEndpointID = "logs" + ComprehendEndpointID = "comprehend" + ComputeOptimizerEndpointID = "computeoptimizer" + IdentityStoreEndpointID = "identitystore" + Inspector2EndpointID = "inspector2" + IVSChatEndpointID = "ivschat" + KendraEndpointID = "kendra" + MediaLiveEndpointID = "medialive" + OpenSearchServerlessEndpointID = "aoss" + PipesEndpointID = "pipes" + ResourceExplorer2EndpointID = "resource-explorer-2" + RolesAnywhereEndpointID = "rolesanywhere" + Route53DomainsEndpointID = "route53domains" + SchedulerEndpointID = "scheduler" + SESV2EndpointID = "sesv2" + SSMEndpointID = "ssm" + TranscribeEndpointID = "transcribe" ) // Type ServiceDatum corresponds closely to columns in `names_data.csv` and are diff --git a/names/names_data.csv b/names/names_data.csv index 561d3e8c7c9..f96f840f741 100644 --- a/names/names_data.csv +++ b/names/names_data.csv @@ -252,6 +252,7 @@ networkmanager,networkmanager,networkmanager,networkmanager,,networkmanager,,,Ne ,,,,,,,,,,,,,,,,,NICE DCV,,x,,,,No SDK support nimble,nimble,nimblestudio,nimble,,nimble,,nimblestudio,Nimble,NimbleStudio,,1,,,aws_nimble_,,nimble_,Nimble Studio,Amazon,,,,, opensearch,opensearch,opensearchservice,opensearch,,opensearch,,opensearchservice,OpenSearch,OpenSearchService,,1,,,aws_opensearch_,,opensearch_,OpenSearch,Amazon,,,,, +opensearchserverless,opensearchserverless,opensearchserverless,opensearchserverless,,opensearchserverless,,,OpenSearchServerless,OpenSearchServerless,,,2,,aws_opensearchserverless_,,opensearchserverless_,OpenSearch Serverless,Amazon,,,,, opsworks,opsworks,opsworks,opsworks,,opsworks,,,OpsWorks,OpsWorks,,1,,,aws_opsworks_,,opsworks_,OpsWorks,AWS,,,,, opsworks-cm,opsworkscm,opsworkscm,opsworkscm,,opsworkscm,,,OpsWorksCM,OpsWorksCM,,1,,,aws_opsworkscm_,,opsworkscm_,OpsWorks CM,AWS,,,,, organizations,organizations,organizations,organizations,,organizations,,,Organizations,Organizations,,1,,,aws_organizations_,,organizations_,Organizations,AWS,,,,, diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index e3ae6d58b73..bb8290b4d39 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -213,6 +213,7 @@ Network Firewall Network Manager Nimble Studio OpenSearch +OpenSearch Serverless OpsWorks OpsWorks CM Organizations diff --git a/website/docs/guides/custom-service-endpoints.html.md b/website/docs/guides/custom-service-endpoints.html.md index 92931592350..590b2a55a21 100644 --- a/website/docs/guides/custom-service-endpoints.html.md +++ b/website/docs/guides/custom-service-endpoints.html.md @@ -277,6 +277,7 @@ provider "aws" {
  • networkmanager
  • nimble (or nimblestudio)
  • opensearch (or opensearchservice)
  • +
  • opensearchserverless
  • opsworks
  • opsworkscm
  • organizations