Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Stemcells: only use account sharing... #33

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion driver/copy_ami_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ func copyAmi(encrypted bool, kmsKeyId string, cb ...func(*ec2.EC2, *ec2.Describe
accessibility = resources.PrivateAmiAccessibility
}

var sharedWithAccounts []string
if kmsKeyId != "" {
sharedWithAccounts = []string{awsAccount}
} else {
sharedWithAccounts = []string{}
}

amiDriverConfig := resources.AmiDriverConfig{
ExistingAmiID: amiFixtureID,
DestinationRegion: destinationRegion,
Expand All @@ -100,7 +107,7 @@ func copyAmi(encrypted bool, kmsKeyId string, cb ...func(*ec2.EC2, *ec2.Describe
Accessibility: accessibility,
Encrypted: encrypted,
KmsKeyId: kmsKeyId,
SharedWithAccounts: []string{awsAccount},
SharedWithAccounts: sharedWithAccounts,
},
}

Expand Down
5 changes: 4 additions & 1 deletion driver/kms_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func (d *SDKKmsDriver) ReplicateKey(driverConfig resources.KmsReplicateKeyDriver
d.logger.Printf("Completed ReplicateKey() in %f minutes\n", time.Since(startTime).Minutes())
}(createStartTime)

d.logger.Printf("Replicating kms key: %s\n", driverConfig.KmsKeyId)
d.logger.Printf("Replicating kms key: %s from region %s to region %s\n",
driverConfig.KmsKeyId,
driverConfig.SourceRegion,
driverConfig.TargetRegion)
_, err := d.createKmsClient(driverConfig.SourceRegion).ReplicateKey(&kms.ReplicateKeyInput{
KeyId: &driverConfig.KmsKeyId,
ReplicaRegion: &driverConfig.TargetRegion,
Expand Down