mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
fix(cloudformation): preserve KMS key spec and usage on create (#7612)
* fix(cloudformation): preserve KMS key spec and usage on create * fix(cloudformation): delegate KMS key defaults to service
This commit is contained in:
1 parent
de71d91d8c
commit
f2debe4ce0
6 files changed
+209
-6
No files matched your search
+3
-1
@@ -41,8 +41,10 @@ public class KmsCfnProvisioner implements CfnResourceProvisioner {
|
||||
|
||||
private void provisionKey(StackResource r, JsonNode props, ProvisionContext ctx) {
|
||||
String description = ctx.resolveOptional(props, "Description");
|
||||
String requestedSpec = ctx.resolveOptional(props, "KeySpec");
|
||||
String requestedUsage = ctx.resolveOptional(props, "KeyUsage");
|
||||
Map<String, String> tags = parseCfnTags(props != null ? props.get("Tags") : null, ctx);
|
||||
KmsKey key = kmsService.createKey(description, null, tags, ctx.region());
|
||||
KmsKey key = kmsService.createKey(description, requestedUsage, requestedSpec, null, tags, ctx.region());
|
||||
r.setPhysicalId(key.getKeyId());
|
||||
r.getAttributes().put("Arn", key.getArn());
|
||||
r.getAttributes().put("KeyId", key.getKeyId());
|
||||
|
||||
@@ -152,7 +152,7 @@ public class KmsService implements ResourceProvider {
|
||||
KmsKeyUsage effectiveUsage = Optional.ofNullable(keyUsage)
|
||||
.map(KmsKeyUsage::fromString)
|
||||
.orElse(KmsKeyUsage.ENCRYPT_DECRYPT);
|
||||
KmsKeySpec effectiveSpec = Optional.of(keySpec)
|
||||
KmsKeySpec effectiveSpec = Optional.ofNullable(keySpec)
|
||||
.map(KmsKeySpec::fromString)
|
||||
.orElse(KmsKeySpec.SYMMETRIC_DEFAULT);
|
||||
validateKeyUsageForSpec(effectiveUsage, effectiveSpec);
|
||||
|
||||
Reference in new issue
Block a user