Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2817ba1
Adds create, read, and delete for basic enabling on Encryption Controls
gdavison Nov 17, 2025
4fd773d
Allows upgrading `mode` to `enforce` on creation
gdavison Nov 18, 2025
c555efd
Enables Resource Identity and Import
gdavison Nov 18, 2025
020e238
Corrects test naming
gdavison Nov 18, 2025
56993c6
Replaces deprecated function
gdavison Nov 18, 2025
1ef1f94
Enables modifying `mode`
gdavison Nov 18, 2025
617ea39
Consolidates modifying VPC Encryption Control
gdavison Nov 18, 2025
8c352e2
Adds `resource_exclusions` output
gdavison Nov 19, 2025
a251e04
Enables `_exclusion` inputs
gdavison Nov 19, 2025
f0d6c93
Fixes attributes in tests
gdavison Nov 19, 2025
e788519
Quotes `ImportCheck` values
gdavison Nov 19, 2025
72ec983
Adds `ImportCheckNoResourceAttr`
gdavison Nov 19, 2025
9320dc6
`ImportCheckResourceAttrSet(_, false)` is redundant and treats `""` a…
gdavison Nov 19, 2025
8eb5283
Fixes constants
gdavison Nov 20, 2025
e0b9138
Defines Exclusion attribute types in one place
gdavison Nov 20, 2025
573db28
Handles modifying and importing Exclusion attributes
gdavison Nov 20, 2025
3f18305
Fixes `TestAccVPCVPCEncryptionControl_update_monitorToEnforce_Implici…
gdavison Nov 20, 2025
5051e71
Enables timeouts
gdavison Nov 21, 2025
81cdea2
Enables VCR
gdavison Nov 24, 2025
24d2d4d
Adds generator for missing AWS SDK Paginators
gdavison Nov 24, 2025
ee6ec60
Generate paginators
gdavison Nov 24, 2025
029d253
Replaces deprecated function
gdavison Nov 25, 2025
7129b2b
Adds additional exclusions
gdavison Nov 25, 2025
b1e43c6
Adds tagging support
gdavison Nov 25, 2025
1eac478
Handles enabling VPC Encryption Controls on VPCs with existing associ…
gdavison Nov 26, 2025
8038041
Fix golangci-lint 'whitespace'.
ewbankkit Nov 26, 2025
0105773
Merge branch 'main' into f-vpc-encryption-controls
ewbankkit Nov 26, 2025
5def589
r/vpc_encryption_control: Correct documentation file name.
ewbankkit Nov 26, 2025
7a07983
Fix tflint 'terraform_unused_declarations'.
ewbankkit Nov 26, 2025
9276fee
Run 'make gen'.
ewbankkit Nov 26, 2025
a2f4b6b
r/aws_vpc_encryption_control: Correct documentation subcategory.
ewbankkit Nov 26, 2025
94a5cf9
Correctly handles `tflint` 'terraform_unused_declarations' error
gdavison Nov 26, 2025
132b9bf
`make clean-tidy`
gdavison Nov 26, 2025
3f21e1a
Updates documentation from stub
gdavison Nov 26, 2025
bb55278
Adds CHANGELOG entry
gdavison Nov 26, 2025
d9e50d1
Document 'region' argument.
ewbankkit Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions internal/acctest/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ func ComposeAggregateImportStateCheckFunc(fs ...resource.ImportStateCheckFunc) r
}
}

func ImportCheckNoResourceAttr(key string) resource.ImportStateCheckFunc {
return func(is []*terraform.InstanceState) error {
if len(is) != 1 {
return fmt.Errorf("Attribute '%s' expected 1 instance state, got %d", key, len(is))
}

rs := is[0]
if v, ok := rs.Attributes[key]; ok {
return fmt.Errorf("Attribute '%s' expected no value, got %q", key, v)
}
return nil
}
}

func ImportCheckResourceAttr(key, expected string) resource.ImportStateCheckFunc {
return func(is []*terraform.InstanceState) error {
if len(is) != 1 {
Expand All @@ -36,7 +50,7 @@ func ImportCheckResourceAttr(key, expected string) resource.ImportStateCheckFunc

rs := is[0]
if rs.Attributes[key] != expected {
return fmt.Errorf("Attribute '%s' expected %s, got %s", key, expected, rs.Attributes[key])
return fmt.Errorf("Attribute '%s' expected %q, got %q", key, expected, rs.Attributes[key])
}
return nil
}
Expand All @@ -56,19 +70,15 @@ func ImportMatchResourceAttr(key string, r *regexp.Regexp) resource.ImportStateC
}
}

func ImportCheckResourceAttrSet(key string, set bool) resource.ImportStateCheckFunc {
func ImportCheckResourceAttrSet(key string) resource.ImportStateCheckFunc {
return func(is []*terraform.InstanceState) error {
if len(is) != 1 {
return fmt.Errorf("Attribute '%s' expected 1 instance state, got %d", key, len(is))
}

rs := is[0]
if set && rs.Attributes[key] == "" {
return fmt.Errorf("Attribute '%s' expected to be set, got not set", key)
}

if !set && rs.Attributes[key] != "" {
return fmt.Errorf("Attribute '%s' expected to be not set, got set (%s)", key, rs.Attributes[key])
if rs.Attributes[key] == "" {
return fmt.Errorf("Attribute '%s' expected to be set, had no value", key)
}

return nil
Expand Down
98 changes: 98 additions & 0 deletions internal/generate/paginator/function.gtpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

// {{ .Name }}PaginatorOptions is the paginator options for
// {{ .AWSName }}
type {{ .Name }}PaginatorOptions struct {
// The maximum number of items to return for this request. To get the next page of
// items, make another request with the token returned in the output. For more
// information, see [Pagination].
//
// [Pagination]: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination
Limit int32

// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}

// {{ .Name }}Paginator is a paginator for {{ .AWSName }}
type {{ .Name }}Paginator struct {
options {{ .Name }}PaginatorOptions
client {{ .Name }}APIClient
params *ec2.{{ .AWSName }}Input
nextToken *string
firstPage bool
}

// new{{ .AWSName }}Paginator returns a new {{ .AWSName }}Paginator
{{ if .NoSemgrep -}}
// nosemgrep:ci.{{ .NoSemgrep }}-in-func-name
{{- end }}
func new{{ .AWSName }}Paginator(client {{ .Name }}APIClient, params *ec2.{{ .AWSName }}Input, optFns ...func(*{{ .Name }}PaginatorOptions)) *{{ .Name }}Paginator {
if params == nil {
params = &ec2.{{ .AWSName }}Input{}
}

options := {{ .Name }}PaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults // nosemgrep:ci.semgrep.aws.prefer-pointer-conversion-assignment
}

for _, fn := range optFns {
fn(&options)
}

return &{{ .Name }}Paginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}

// HasMorePages returns a boolean indicating whether more pages are available
func (p *{{ .Name }}Paginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}

// NextPage retrieves the next {{ .AWSName }} page.
func (p *{{ .Name }}Paginator) NextPage(ctx context.Context, optFns ...func(*ec2.Options)) (*ec2.{{ .AWSName }}Output, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}

params := *p.params // nosemgrep:ci.semgrep.aws.prefer-pointer-conversion-assignment
params.NextToken = p.nextToken

var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit

result, err := p.client.{{ .AWSName }}(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false

prevToken := p.nextToken
p.nextToken = result.NextToken

if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken { // nosemgrep:ci.semgrep.aws.prefer-pointer-conversion-conditional
p.nextToken = nil
}

return result, nil
}

// {{ .Name }}APIClient is a client that implements the
// {{ .AWSName }} operation.
type {{ .Name }}APIClient interface {
{{ .AWSName }}(context.Context, *ec2.{{ .AWSName }}Input, ...func(*ec2.Options)) (*ec2.{{ .AWSName }}Output, error)
}

var _ {{ .Name }}APIClient = (*ec2.Client)(nil)
10 changes: 10 additions & 0 deletions internal/generate/paginator/header.gtpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Code generated by "internal/generate/listpages/main.go {{ .Parameters }}"; DO NOT EDIT.

package {{ .DestinationPackage }}

import (
"context"
"fmt"

"{{ .SourcePackage }}"
)
Loading
Loading