Skip to content

Commit

Permalink
Merge pull request #33 from cloudfoundry/kms-shared-accounts
Browse files Browse the repository at this point in the history
AWS Stemcells: only use account sharing...
  • Loading branch information
jpalermo committed Nov 22, 2023
2 parents c0619f5 + 24752fb commit edae318
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit edae318

Please sign in to comment.