-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20533 from bshelton/f-aws_multi_region_kms_key
Adding support for multi-region for aws_kms_key resource
- Loading branch information
Showing
22 changed files
with
2,155 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
```release-note:enhancement | ||
resource/aws_kms_key: Add `multi_region` argument | ||
``` | ||
|
||
```release-note:enhancement | ||
data-source/aws_kms_key: Add `multi_region` and `multi_region_configuration` attributes | ||
``` | ||
|
||
```release-note:new-resource | ||
aws_kms_replica_key | ||
``` | ||
|
||
```release-note:enhancement | ||
resource/aws_kms_external_key: Add `multi_region` argument | ||
``` | ||
|
||
```release-note:new-resource | ||
aws_kms_replica_external_key | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/endpoints" | ||
"github.com/aws/aws-sdk-go/aws/request" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/accessanalyzer" | ||
"github.com/aws/aws-sdk-go/service/acm" | ||
"github.com/aws/aws-sdk-go/service/acmpca" | ||
|
@@ -448,12 +449,7 @@ func (c *Config) Client() (interface{}, error) { | |
SkipRequestingAccountId: c.SkipRequestingAccountId, | ||
StsEndpoint: c.Endpoints["sts"], | ||
Token: c.Token, | ||
UserAgentProducts: []*awsbase.UserAgentProduct{ | ||
{Name: "APN", Version: "1.0"}, | ||
{Name: "HashiCorp", Version: "1.0"}, | ||
{Name: "Terraform", Version: c.TerraformVersion, Extra: []string{"+https://www.terraform.io"}}, | ||
{Name: "terraform-provider-aws", Version: version.ProviderVersion, Extra: []string{"+https://registry.terraform.io/providers/hashicorp/aws"}}, | ||
}, | ||
UserAgentProducts: StdUserAgentProducts(c.TerraformVersion), | ||
} | ||
|
||
sess, accountID, Partition, err := awsbase.GetSessionWithAccountIDAndPartition(awsbaseConfig) | ||
|
@@ -941,6 +937,32 @@ func (c *Config) Client() (interface{}, error) { | |
return client, nil | ||
} | ||
|
||
func StdUserAgentProducts(terraformVersion string) []*awsbase.UserAgentProduct { | ||
return []*awsbase.UserAgentProduct{ | ||
{Name: "APN", Version: "1.0"}, | ||
{Name: "HashiCorp", Version: "1.0"}, | ||
{Name: "Terraform", Version: terraformVersion, Extra: []string{"+https://www.terraform.io"}}, | ||
{Name: "terraform-provider-aws", Version: version.ProviderVersion, Extra: []string{"+https://registry.terraform.io/providers/hashicorp/aws"}}, | ||
} | ||
} | ||
|
||
func NewSessionForRegion(cfg *aws.Config, region, terraformVersion string) (*session.Session, error) { | ||
session, err := session.NewSession(cfg) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
userAgentProducts := StdUserAgentProducts(terraformVersion) | ||
// Copied from github.com/hashicorp/[email protected]/session.go: | ||
for i := len(userAgentProducts) - 1; i >= 0; i-- { | ||
product := userAgentProducts[i] | ||
session.Handlers.Build.PushFront(request.MakeAddToUserAgentHandler(product.Name, product.Version, product.Extra...)) | ||
} | ||
|
||
return session.Copy(&aws.Config{Region: aws.String(region)}), nil | ||
} | ||
|
||
func HasEC2Classic(platforms []string) bool { | ||
for _, p := range platforms { | ||
if p == "EC2" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.