fix(cloudformation): create an EKS cluster with its encryption and network settings, a replacement included (#8739)

This commit is contained in:
Oleksandr Nikolaichuk authored and GitHub committed 2026-11-17 18:53:23 -04:00
1 parent 77a4a1ff65
commit 523eba559e
13 files changed
+536 -55

No files matched your search

+1 -1
View File
@@ -219,7 +219,7 @@ cross-resource references.
| ECR | `Repository` |
| ECS | `Cluster`, `TaskDefinition`, `Service`, `CapacityProvider`, `ClusterCapacityProviderAssociations` |
| EFS | `FileSystem` (metadata only, there is no NFS data plane), `MountTarget` (`SecurityGroups` update in place, every other property replaces), `AccessPoint` (`AccessPointTags` update in place, every other property replaces) |
| EKS | `Cluster` (created with `Name`, `Version`, `RoleArn` and `Tags`, a replacement included; `EncryptionConfig` and `KubernetesNetworkConfig` are accepted and ignored on create; updated in place for `Tags`, keeping tags added outside the stack; a change to `Name`, `RoleArn`, `EncryptionConfig`, `BootstrapSelfManagedAddons`, `OutpostConfig`, `AccessConfig.BootstrapClusterCreatorAdminPermissions`, `KubernetesNetworkConfig.IpFamily` or `KubernetesNetworkConfig.ServiceIpv4Cidr` replaces the cluster, as the registry marks them create-only, and deletes the old one once the update commits; a change to `Version` is accepted with a warning and not applied, as the emulator cannot upgrade a cluster in place), `Nodegroup` (created with `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets` and `Tags`; updated in place for `Tags`, keeping tags added outside the stack; a change to `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets`, `AmiType`, `CapacityType`, `DiskSize`, `InstanceTypes` or `RemoteAccess` replaces the nodegroup, as the registry marks them create-only, and deletes the old one once the update commits; `ScalingConfig`, `Labels`, `Taints`, `UpdateConfig`, `Version`, `ReleaseVersion`, `ForceUpdateEnabled`, `LaunchTemplate`, `NodeRepairConfig` and `WarmPoolConfig` are accepted and not applied, whether changed or dropped, with a warning, as the emulator cannot update a nodegroup in place) |
| EKS | `Cluster` (created with `Name`, `Version`, `RoleArn`, `Tags`, `EncryptionConfig` and `KubernetesNetworkConfig.IpFamily` and `ServiceIpv4Cidr`, a replacement included; a change to `EncryptionConfig`, `IpFamily` or `ServiceIpv4Cidr` replaces the cluster with the new value applied; `ElasticLoadBalancing` and `ServiceIpv6Cidr` are accepted and ignored; updated in place for `Tags`, keeping tags added outside the stack; a change to `Name`, `RoleArn`, `EncryptionConfig`, `BootstrapSelfManagedAddons`, `OutpostConfig`, `AccessConfig.BootstrapClusterCreatorAdminPermissions`, `KubernetesNetworkConfig.IpFamily` or `KubernetesNetworkConfig.ServiceIpv4Cidr` replaces the cluster, as the registry marks them create-only, and deletes the old one once the update commits; a change to `Version` is accepted with a warning and not applied, as the emulator cannot upgrade a cluster in place), `Nodegroup` (created with `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets` and `Tags`; updated in place for `Tags`, keeping tags added outside the stack; a change to `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets`, `AmiType`, `CapacityType`, `DiskSize`, `InstanceTypes` or `RemoteAccess` replaces the nodegroup, as the registry marks them create-only, and deletes the old one once the update commits; `ScalingConfig`, `Labels`, `Taints`, `UpdateConfig`, `Version`, `ReleaseVersion`, `ForceUpdateEnabled`, `LaunchTemplate`, `NodeRepairConfig` and `WarmPoolConfig` are accepted and not applied, whether changed or dropped, with a warning, as the emulator cannot update a nodegroup in place) |
| RDS | `DBInstance` (starts a real container), `DBCluster` (starts a real container), `DBSubnetGroup`, `DBParameterGroup`, `DBClusterParameterGroup`, `DBProxy`, `DBProxyTargetGroup` |
| Aurora DSQL | `Cluster` |
| ElastiCache | `CacheCluster` (starts a real container; modifying an existing cluster in place is not supported), `ReplicationGroup` (starts a real container; modifying an existing group in place is not supported), `SubnetGroup`, `User` (Tags are ignored), `UserGroup` (Tags are ignored), `ServerlessCache` (GetAtt uses the dotted Endpoint.* and ReaderEndpoint.* form) |
@@ -349,6 +349,17 @@ final class CfnPropertyTypes {
return read(path, path.substring(path.lastIndexOf('/') + 1), engine.omitNoValue(raw), shapeName);
}
/**
* The property {@code property} of {@code resourceType} in {@code props} read as the shape its
* resource schema declares; null when {@code props} lacks it or it is {@code AWS::NoValue}.
*/
JsonNode readProperty(String resourceType, JsonNode props, String property) {
if (props == null || !props.has(property)) {
return null;
}
return read(property, props.get(property), propertyShape(resourceType, property));
}
/** Throws the first model validation failure found by {@link #read}, if any. */
void finish() {
if (modelFailure != null) {
@@ -53,11 +53,11 @@ public class DsqlCfnProvisioner implements CfnResourceProvisioner {
public void provision(StackResource resource, JsonNode props, ProvisionContext ctx) {
String region = ctx.region();
CfnPropertyTypes.Reader types = new CfnPropertyTypes.Reader(ctx.engine());
JsonNode protection = read(types, props, "DeletionProtectionEnabled");
JsonNode kmsKey = read(types, props, "KmsEncryptionKey");
JsonNode multiRegion = read(types, props, "MultiRegionProperties");
JsonNode tagList = read(types, props, "Tags");
JsonNode policyDocument = read(types, props, "PolicyDocument");
JsonNode protection = types.readProperty(TYPE, props, "DeletionProtectionEnabled");
JsonNode kmsKey = types.readProperty(TYPE, props, "KmsEncryptionKey");
JsonNode multiRegion = types.readProperty(TYPE, props, "MultiRegionProperties");
JsonNode tagList = types.readProperty(TYPE, props, "Tags");
JsonNode policyDocument = types.readProperty(TYPE, props, "PolicyDocument");
types.finish();
Boolean deletionProtection = protection == null ? null : protection.booleanValue();
String kms = kmsKey == null ? null : kmsKey.asText();
@@ -104,11 +104,6 @@ public class DsqlCfnProvisioner implements CfnResourceProvisioner {
() -> dsqlService.deleteCluster(region, physicalId), "ResourceNotFoundException");
}
private static JsonNode read(CfnPropertyTypes.Reader types, JsonNode props, String property) {
return props == null ? null
: types.read(property, props.get(property), CfnPropertyTypes.propertyShape(TYPE, property));
}
private DsqlCluster awaitSettled(String region, String identifier) {
Instant deadline = Instant.now().plus(READY_TIMEOUT);
while (true) {
@@ -1,5 +1,6 @@
package io.floci.aws.services.cloudformation.provisioners;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -110,6 +111,9 @@ public class EksCfnProvisioner implements CfnResourceProvisioner {
// Unstripped: createCluster reads the reserved cluster-args tag, then drops it.
Map<String, String> templateTags = ctx.resolveTags(props, "Tags");
request.setTags(templateTags);
request.setEncryptionConfig(createSetting(props, "EncryptionConfig", ctx, new TypeReference<>() { }));
request.setKubernetesNetworkConfig(
createSetting(props, "KubernetesNetworkConfig", ctx, new TypeReference<>() { }));
Cluster created = eksService.createCluster(request);
// The cluster this resource named before is gone or replaced; publish writes only what the
// new one has, so its endpoint and certificate must not outlive it.
@@ -127,6 +131,28 @@ public class EksCfnProvisioner implements CfnResourceProvisioner {
}
}
/**
* A create-only property in its API request shape, or null when the template leaves it out. The
* template value is read against the type the resource schema declares, so a value of another type
* fails the resource with CloudFormation's wording. The request model has no ElasticLoadBalancing
* or ServiceIpv6Cidr member, so those members of KubernetesNetworkConfig are not read.
*/
private static <T> T createSetting(JsonNode props, String name, ProvisionContext ctx, TypeReference<T> type) {
CfnPropertyTypes.Reader types = new CfnPropertyTypes.Reader(ctx.engine());
JsonNode resolved = types.readProperty(CLUSTER, props, name);
types.finish();
if (resolved == null) {
return null;
}
try {
return MAPPER.convertValue(CfnApiShapeConverter.convert(resolved, CfnApiShapeConverter.OMIT_NULL_PROPERTIES),
type);
} catch (IllegalArgumentException e) {
throw new AwsException("ValidationError", "AWS::EKS::Cluster " + name + " is not valid: "
+ e.getMessage(), 400);
}
}
private void publish(StackResource r, Cluster cluster) {
r.setPhysicalId(cluster.getName());
r.getAttributes().put("Arn", cluster.getArn());
@@ -800,7 +800,7 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
}
private Map<String, String> resolveLambdaEnvironment(CfnPropertyTypes.Reader types, JsonNode props) {
JsonNode envNode = readTyped(types, FUNCTION, props, "Environment");
JsonNode envNode = types.readProperty(FUNCTION, props, "Environment");
JsonNode variables = envNode == null ? null : envNode.get("Variables");
if (variables == null) {
return Map.of();
@@ -812,7 +812,7 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
private static List<String> resolveStringListOrEmpty(CfnPropertyTypes.Reader types, String resourceType,
JsonNode props, String source) {
JsonNode values = readTyped(types, resourceType, props, source);
JsonNode values = types.readProperty(resourceType, props, source);
return values == null ? List.of() : texts(values);
}
@@ -823,7 +823,7 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
}
private List<Object> resolveObjectListOrEmpty(CfnPropertyTypes.Reader types, JsonNode props, String source) {
JsonNode resolved = readTyped(types, FUNCTION, props, source);
JsonNode resolved = types.readProperty(FUNCTION, props, source);
if (resolved == null) {
return List.of();
}
@@ -835,24 +835,10 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
/** The object property {@code source}, or {@code defaultValue} when the template leaves it out. */
private Map<String, Object> resolveMapOrDefault(CfnPropertyTypes.Reader types, JsonNode props, String source,
Map<String, Object> defaultValue) {
JsonNode resolved = readTyped(types, FUNCTION, props, source);
JsonNode resolved = types.readProperty(FUNCTION, props, source);
return resolved == null ? defaultValue : jsonObjectToMap(resolved);
}
/**
* The property {@code source} of {@code resourceType} read against the type its resource schema
* declares, or null when the template leaves it out, {@code Ref: AWS::NoValue} directly or
* through {@code Fn::If} included. A value of another type is refused before the function is
* touched; see {@link CfnPropertyTypes}.
*/
private static JsonNode readTyped(CfnPropertyTypes.Reader types, String resourceType, JsonNode props,
String source) {
if (props == null || !props.has(source)) {
return null;
}
return types.read(source, props.get(source), CfnPropertyTypes.propertyShape(resourceType, source));
}
private static Map<String, Object> mapWithNullValue(String key) {
Map<String, Object> map = new HashMap<>();
map.put(key, null);
@@ -861,7 +847,7 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
private void putStringListIfPresent(Map<String, Object> request, CfnPropertyTypes.Reader types,
JsonNode props, String source) {
JsonNode values = readTyped(types, FUNCTION, props, source);
JsonNode values = types.readProperty(FUNCTION, props, source);
if (values != null) {
request.put(source, texts(values));
}
@@ -869,7 +855,7 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
private void putResolvedMapIfPresent(Map<String, Object> request, CfnPropertyTypes.Reader types,
JsonNode props, String source) {
JsonNode resolved = readTyped(types, FUNCTION, props, source);
JsonNode resolved = types.readProperty(FUNCTION, props, source);
if (resolved != null) {
request.put(source, jsonObjectToMap(resolved));
}
@@ -815,6 +815,8 @@ public class EksService implements TagHandler, ResourceProvider, Ec2InstanceLaun
}
cluster.setTags(request.getTags() != null ? ReservedTags.stripReservedTags(request.getTags()) : new HashMap<>());
// Refused before the cluster security group exists, so a bad ipFamily leaves nothing behind.
resolveIpFamily(request.getKubernetesNetworkConfig());
ResourcesVpcConfig vpcConfig = buildVpcConfigResponse(request.getResourcesVpcConfig(), resolvedVpcId);
SecurityGroup clusterSg = null;
if (ec2Service != null && !vpcConfig.getVpcId().isBlank()) {
@@ -1789,10 +1791,19 @@ public class EksService implements TagHandler, ResourceProvider, Ec2InstanceLaun
}
}
config.setServiceIpv4Cidr(resolvedCidr);
config.setIpFamily(request != null && request.getIpFamily() != null ? request.getIpFamily() : "ipv4");
config.setIpFamily(resolveIpFamily(request));
return config;
}
private static String resolveIpFamily(KubernetesNetworkConfig request) {
String ipFamily = request != null && request.getIpFamily() != null ? request.getIpFamily() : "ipv4";
if (!"ipv4".equals(ipFamily) && !"ipv6".equals(ipFamily)) {
throw new AwsException("InvalidParameterException",
"Invalid ipFamily '" + ipFamily + "'. Valid values: ipv4 | ipv6", 400);
}
return ipFamily;
}
static Logging defaultLogging() {
return new Logging(List.of(new LogSetup(new ArrayList<>(ALL_LOG_TYPES), false)));
}
@@ -1855,8 +1866,10 @@ public class EksService implements TagHandler, ResourceProvider, Ec2InstanceLaun
"Only one encryption configuration is allowed", 400);
}
EncryptionConfig config = requestedConfigs.getFirst();
if (config == null || config.getResources() == null || config.getResources().isEmpty()
|| !List.of("secrets").equals(config.getResources())) {
// AWS: Resources is optional, "this field no longer affects which resources are encrypted", and
// "secrets" is the only supported value.
boolean resourcesOmitted = config != null && (config.getResources() == null || config.getResources().isEmpty());
if (config == null || !(resourcesOmitted || List.of("secrets").equals(config.getResources()))) {
throw new AwsException("InvalidParameterException",
"Invalid k8s resource and provider for encryption", 400);
}
+394 -16
View File
@@ -2,7 +2,7 @@
"_source": {
"generator": "tools/aws/regen_cfn_property_types.py",
"schemas": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip",
"retrieved": "2026-11-16",
"retrieved": "2026-11-17",
"note": "make cfn-property-types-verify checks the file against AWS."
},
"operations": {
@@ -11,6 +11,7 @@
"AWS::EC2::Instance": "AWS::EC2::Instance",
"AWS::EC2::LaunchTemplate": "AWS::EC2::LaunchTemplate",
"AWS::ECS::TaskDefinition": "AWS::ECS::TaskDefinition",
"AWS::EKS::Cluster": "AWS::EKS::Cluster",
"AWS::Events::Rule": "AWS::Events::Rule",
"AWS::Lambda::Function": "AWS::Lambda::Function",
"AWS::Lambda::LayerVersion": "AWS::Lambda::LayerVersion",
@@ -92,35 +93,40 @@
"AWS::DSQL::Cluster": {
"type": "structure",
"members": {
"Status": "String",
"PolicyVersion": "String",
"EncryptionDetails": "AWS::DSQL::Cluster.EncryptionDetails",
"KmsEncryptionKey": "String",
"MultiRegionProperties": "AWS::DSQL::Cluster.MultiRegionProperties",
"DeletionProtectionEnabled": "Boolean",
"Tags": "AWS::DSQL::Cluster.Tags",
"ResourceArn": "String",
"Identifier": "String",
"VpcEndpointServiceName": "String",
"VpcEndpoint": "String",
"Endpoint": "String",
"CreationTime": "String",
"Status": "String",
"VpcEndpointServiceName": "String",
"MultiRegionProperties": "AWS::DSQL::Cluster.MultiRegionProperties",
"KmsEncryptionKey": "String",
"EncryptionDetails": "AWS::DSQL::Cluster.EncryptionDetails",
"Endpoint": "String",
"VpcEndpoint": "String",
"PolicyVersion": "String",
"PolicyDocument": "String",
"DeletionProtectionEnabled": "Boolean",
"Tags": "AWS::DSQL::Cluster.Tags"
"MetricGroups": "AWS::DSQL::Cluster.MetricGroups"
}
},
"AWS::DSQL::Cluster.EncryptionDetails": {
"type": "structure",
"members": {
"EncryptionType": "String",
"EncryptionStatus": "String",
"EncryptionType": "String",
"KmsKeyArn": "String"
}
},
"AWS::DSQL::Cluster.MetricGroups": {
"type": "list",
"member": "AWS::DSQL::Cluster/MetricGroup"
},
"AWS::DSQL::Cluster.MultiRegionProperties": {
"type": "structure",
"members": {
"Clusters": "AWS::DSQL::Cluster.MultiRegionProperties.Clusters",
"WitnessRegion": "String"
"WitnessRegion": "String",
"Clusters": "AWS::DSQL::Cluster.MultiRegionProperties.Clusters"
}
},
"AWS::DSQL::Cluster.MultiRegionProperties.Clusters": {
@@ -131,11 +137,20 @@
"type": "list",
"member": "AWS::DSQL::Cluster/Tag"
},
"AWS::DSQL::Cluster/MetricGroup": {
"type": "structure",
"members": {
"MetricGroup": "String"
},
"required": [
"MetricGroup"
]
},
"AWS::DSQL::Cluster/Tag": {
"type": "structure",
"members": {
"Value": "String",
"Key": "String"
"Key": "String",
"Value": "String"
},
"required": [
"Key",
@@ -1532,6 +1547,369 @@
"SourceContainer": "String"
}
},
"AWS::EKS::Cluster": {
"type": "structure",
"members": {
"EncryptionConfig": "AWS::EKS::Cluster.EncryptionConfig",
"KubernetesNetworkConfig": "AWS::EKS::Cluster/KubernetesNetworkConfig",
"Logging": "AWS::EKS::Cluster/Logging",
"Name": "String",
"Id": "String",
"ResourcesVpcConfig": "AWS::EKS::Cluster/ResourcesVpcConfig",
"OutpostConfig": "AWS::EKS::Cluster/OutpostConfig",
"AccessConfig": "AWS::EKS::Cluster/AccessConfig",
"UpgradePolicy": "AWS::EKS::Cluster/UpgradePolicy",
"RemoteNetworkConfig": "AWS::EKS::Cluster/RemoteNetworkConfig",
"ComputeConfig": "AWS::EKS::Cluster/ComputeConfig",
"StorageConfig": "AWS::EKS::Cluster/StorageConfig",
"RoleArn": "String",
"Version": "String",
"Force": "Boolean",
"RollbackConfig": "AWS::EKS::Cluster/RollbackConfig",
"Tags": "AWS::EKS::Cluster.Tags",
"Arn": "String",
"Endpoint": "String",
"CertificateAuthorityData": "String",
"ActiveCertificateAuthorityId": "String",
"CertificateAuthority": "AWS::EKS::Cluster/CertificateAuthority",
"ClusterSecurityGroupId": "String",
"EncryptionConfigKeyArn": "String",
"OpenIdConnectIssuerUrl": "String",
"BootstrapSelfManagedAddons": "Boolean",
"DeletionProtection": "Boolean",
"ZonalShiftConfig": "AWS::EKS::Cluster/ZonalShiftConfig",
"ControlPlaneScalingConfig": "AWS::EKS::Cluster/ControlPlaneScalingConfig",
"KubeApiServerConfig": "AWS::EKS::Cluster/KubeApiServerConfig",
"KubeSchedulerConfig": "AWS::EKS::Cluster/KubeSchedulerConfig",
"KubeControllerManagerConfig": "AWS::EKS::Cluster/KubeControllerManagerConfig"
},
"required": [
"RoleArn",
"ResourcesVpcConfig"
]
},
"AWS::EKS::Cluster.EncryptionConfig": {
"type": "list",
"member": "AWS::EKS::Cluster/EncryptionConfig"
},
"AWS::EKS::Cluster.Tags": {
"type": "list",
"member": "AWS::EKS::Cluster/Tag"
},
"AWS::EKS::Cluster/AccessConfig": {
"type": "structure",
"members": {
"BootstrapClusterCreatorAdminPermissions": "Boolean",
"AuthenticationMode": "String"
}
},
"AWS::EKS::Cluster/ActiveCertificateAuthority": {
"type": "structure",
"members": {
"Id": "String",
"ActivatedBy": "String"
}
},
"AWS::EKS::Cluster/BlockStorage": {
"type": "structure",
"members": {
"Enabled": "Boolean"
}
},
"AWS::EKS::Cluster/CertificateAuthority": {
"type": "structure",
"members": {
"Data": "String",
"Active": "AWS::EKS::Cluster/ActiveCertificateAuthority"
}
},
"AWS::EKS::Cluster/ClusterLogging": {
"type": "structure",
"members": {
"EnabledTypes": "AWS::EKS::Cluster/EnabledTypes"
}
},
"AWS::EKS::Cluster/ComputeConfig": {
"type": "structure",
"members": {
"Enabled": "Boolean",
"NodeRoleArn": "String",
"NodePools": "AWS::EKS::Cluster/ComputeConfig.NodePools"
}
},
"AWS::EKS::Cluster/ComputeConfig.NodePools": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/ControlPlanePlacement": {
"type": "structure",
"members": {
"GroupName": "String",
"SpreadLevel": "String"
}
},
"AWS::EKS::Cluster/ControlPlaneScalingConfig": {
"type": "structure",
"members": {
"Tier": "String"
}
},
"AWS::EKS::Cluster/ElasticLoadBalancing": {
"type": "structure",
"members": {
"Enabled": "Boolean",
"GatewayApi": "AWS::EKS::Cluster/GatewayApi"
}
},
"AWS::EKS::Cluster/EnabledTypes": {
"type": "list",
"member": "AWS::EKS::Cluster/LoggingTypeConfig"
},
"AWS::EKS::Cluster/EncryptionConfig": {
"type": "structure",
"members": {
"Provider": "AWS::EKS::Cluster/Provider",
"Resources": "AWS::EKS::Cluster/EncryptionConfig.Resources"
}
},
"AWS::EKS::Cluster/EncryptionConfig.Resources": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/EtcdPlacement": {
"type": "structure",
"members": {
"SpreadLevel": "String"
}
},
"AWS::EKS::Cluster/GatewayApi": {
"type": "structure",
"members": {
"Crds": "AWS::EKS::Cluster/GatewayApiCrds"
},
"required": [
"Crds"
]
},
"AWS::EKS::Cluster/GatewayApiCrds": {
"type": "structure",
"members": {
"Managed": "Boolean"
},
"required": [
"Managed"
]
},
"AWS::EKS::Cluster/HorizontalPodAutoscalerControllerConfig": {
"type": "structure",
"members": {
"HorizontalPodAutoscalerSyncPeriod": "String"
}
},
"AWS::EKS::Cluster/KubeApiServerConfig": {
"type": "structure",
"members": {
"EventTtl": "String",
"ServiceNodePortRange": "AWS::EKS::Cluster/ServiceNodePortRange"
}
},
"AWS::EKS::Cluster/KubeControllerManagerConfig": {
"type": "structure",
"members": {
"PodGcControllerConfig": "AWS::EKS::Cluster/PodGcControllerConfig",
"HorizontalPodAutoscalerControllerConfig": "AWS::EKS::Cluster/HorizontalPodAutoscalerControllerConfig"
}
},
"AWS::EKS::Cluster/KubeSchedulerConfig": {
"type": "structure",
"members": {
"NodeResourcesFit": "AWS::EKS::Cluster/NodeResourcesFitConfig"
}
},
"AWS::EKS::Cluster/KubernetesNetworkConfig": {
"type": "structure",
"members": {
"ServiceIpv4Cidr": "String",
"ServiceIpv6Cidr": "String",
"IpFamily": "String",
"ElasticLoadBalancing": "AWS::EKS::Cluster/ElasticLoadBalancing"
}
},
"AWS::EKS::Cluster/Logging": {
"type": "structure",
"members": {
"ClusterLogging": "AWS::EKS::Cluster/ClusterLogging"
}
},
"AWS::EKS::Cluster/LoggingTypeConfig": {
"type": "structure",
"members": {
"Type": "String"
}
},
"AWS::EKS::Cluster/NodeResourcesFitConfig": {
"type": "structure",
"members": {
"ScoringStrategy": "AWS::EKS::Cluster/ScoringStrategy"
}
},
"AWS::EKS::Cluster/OutpostConfig": {
"type": "structure",
"members": {
"OutpostArns": "AWS::EKS::Cluster/OutpostConfig.OutpostArns",
"ControlPlaneInstanceType": "String",
"ControlPlanePlacement": "AWS::EKS::Cluster/ControlPlanePlacement",
"EtcdInstanceType": "String",
"EtcdPlacement": "AWS::EKS::Cluster/EtcdPlacement"
},
"required": [
"OutpostArns",
"ControlPlaneInstanceType"
]
},
"AWS::EKS::Cluster/OutpostConfig.OutpostArns": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/PodGcControllerConfig": {
"type": "structure",
"members": {
"TerminatedPodGcThreshold": "Integer"
}
},
"AWS::EKS::Cluster/Provider": {
"type": "structure",
"members": {
"KeyArn": "String"
}
},
"AWS::EKS::Cluster/RemoteNetworkConfig": {
"type": "structure",
"members": {
"RemoteNodeNetworks": "AWS::EKS::Cluster/RemoteNodeNetworks",
"RemotePodNetworks": "AWS::EKS::Cluster/RemotePodNetworks"
}
},
"AWS::EKS::Cluster/RemoteNodeNetwork": {
"type": "structure",
"members": {
"Cidrs": "AWS::EKS::Cluster/RemoteNodeNetwork.Cidrs"
},
"required": [
"Cidrs"
]
},
"AWS::EKS::Cluster/RemoteNodeNetwork.Cidrs": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/RemoteNodeNetworks": {
"type": "list",
"member": "AWS::EKS::Cluster/RemoteNodeNetwork"
},
"AWS::EKS::Cluster/RemotePodNetwork": {
"type": "structure",
"members": {
"Cidrs": "AWS::EKS::Cluster/RemotePodNetwork.Cidrs"
},
"required": [
"Cidrs"
]
},
"AWS::EKS::Cluster/RemotePodNetwork.Cidrs": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/RemotePodNetworks": {
"type": "list",
"member": "AWS::EKS::Cluster/RemotePodNetwork"
},
"AWS::EKS::Cluster/ResourceWeight": {
"type": "structure",
"members": {
"Name": "String",
"Weight": "Integer"
}
},
"AWS::EKS::Cluster/ResourcesVpcConfig": {
"type": "structure",
"members": {
"EndpointPrivateAccess": "Boolean",
"EndpointPublicAccess": "Boolean",
"PublicAccessCidrs": "AWS::EKS::Cluster/ResourcesVpcConfig.PublicAccessCidrs",
"SecurityGroupIds": "AWS::EKS::Cluster/ResourcesVpcConfig.SecurityGroupIds",
"SubnetIds": "AWS::EKS::Cluster/ResourcesVpcConfig.SubnetIds",
"ControlPlaneEgressMode": "String"
},
"required": [
"SubnetIds"
]
},
"AWS::EKS::Cluster/ResourcesVpcConfig.PublicAccessCidrs": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/ResourcesVpcConfig.SecurityGroupIds": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/ResourcesVpcConfig.SubnetIds": {
"type": "list",
"member": "String"
},
"AWS::EKS::Cluster/RollbackConfig": {
"type": "structure",
"members": {
"TimeoutMinutes": "Integer"
}
},
"AWS::EKS::Cluster/ScoringStrategy": {
"type": "structure",
"members": {
"Type": "String",
"Resources": "AWS::EKS::Cluster/ScoringStrategy.Resources"
}
},
"AWS::EKS::Cluster/ScoringStrategy.Resources": {
"type": "list",
"member": "AWS::EKS::Cluster/ResourceWeight"
},
"AWS::EKS::Cluster/ServiceNodePortRange": {
"type": "structure",
"members": {
"MinPort": "Integer",
"MaxPort": "Integer"
}
},
"AWS::EKS::Cluster/StorageConfig": {
"type": "structure",
"members": {
"BlockStorage": "AWS::EKS::Cluster/BlockStorage"
}
},
"AWS::EKS::Cluster/Tag": {
"type": "structure",
"members": {
"Key": "String",
"Value": "String"
},
"required": [
"Key",
"Value"
]
},
"AWS::EKS::Cluster/UpgradePolicy": {
"type": "structure",
"members": {
"SupportType": "String"
}
},
"AWS::EKS::Cluster/ZonalShiftConfig": {
"type": "structure",
"members": {
"Enabled": "Boolean"
}
},
"AWS::Events::Rule": {
"type": "structure",
"members": {
@@ -206,6 +206,66 @@ class CloudFormationEksIntegrationTest {
+ team + "\"}" + (extraTag.isEmpty() ? "" : ", " + extraTag) + "]");
}
@Test
void aClusterIsCreatedWithItsEncryptionAndNetworkSettings() {
String stack = "cfn-eks-set-" + Long.toString(System.nanoTime(), 36);
String key = "arn:aws:kms:us-east-1:000000000000:key/11111111-2222-3333-4444-555555555555";
String listed = "\"EncryptionConfig\": [{\"Provider\": {\"KeyArn\": \"" + key
+ "\"}, \"Resources\": [\"secrets\"]}], " + NETWORK;
String bare = "\"EncryptionConfig\": [{\"Provider\": {\"KeyArn\": \"" + key + "\"}}]";
String template = "{\"Resources\": {"
+ "\"Subject\": {\"Type\": \"AWS::EKS::Cluster\", \"Properties\": {" + ROLE + listed + "}},"
+ "\"Bare\": {\"Type\": \"AWS::EKS::Cluster\", \"Properties\": {" + ROLE + bare + "}}}}";
try (CloudFormationClient client = AwsTestClients.create(
CloudFormationClient.builder(), "test", Region.US_EAST_1)) {
CfnStackWaits.createStack(client, stack, template, "CREATE_COMPLETE");
JsonPath cluster = given().get("/clusters/" + physicalId(client, stack, "Subject")).jsonPath();
assertEquals(key, cluster.getString("cluster.encryptionConfig[0].provider.keyArn"));
assertEquals(List.of("secrets"), cluster.getList("cluster.encryptionConfig[0].resources"));
assertEquals("172.20.0.0/16", cluster.getString("cluster.kubernetesNetworkConfig.serviceIpv4Cidr"));
assertEquals(List.of("secrets"), given().get("/clusters/" + physicalId(client, stack, "Bare"))
.jsonPath().getList("cluster.encryptionConfig[0].resources"));
} finally {
CfnStackWaits.deleteStack(stack);
}
}
@Test
void aBlankEncryptionConfigFailsTheClusterInsteadOfCreatingItUnencrypted() {
String stack = "cfn-eks-blank-" + Long.toString(System.nanoTime(), 36);
try (CloudFormationClient client = AwsTestClients.create(
CloudFormationClient.builder(), "test", Region.US_EAST_1)) {
CfnStackWaits.createStack(client, stack, subjectStack("", "", "AWS::EKS::Cluster",
ROLE + "\"EncryptionConfig\": \"\""), "ROLLBACK_COMPLETE");
} finally {
CfnStackWaits.deleteStack(stack);
}
}
@Test
void changingTheServiceCidrReplacesTheClusterWithTheNewOne() {
String stack = "cfn-eks-cidr-" + Long.toString(System.nanoTime(), 36);
try (CloudFormationClient client = AwsTestClients.create(
CloudFormationClient.builder(), "test", Region.US_EAST_1)) {
CfnStackWaits.createStack(client, stack, subjectStack("", "", "AWS::EKS::Cluster", ROLE + NETWORK),
"CREATE_COMPLETE");
String first = physicalId(client, stack, "Subject");
createUpdateChangeSet(client, stack, "cidr", subjectStack("", "", "AWS::EKS::Cluster",
ROLE + NETWORK.replace("172.20.0.0/16", "192.168.128.0/20")));
executeAndAwaitUpdate(client, stack, "cidr");
String second = physicalId(client, stack, "Subject");
assertNotEquals(first, second);
assertEquals("192.168.128.0/20", given().get("/clusters/" + second).jsonPath()
.getString("cluster.kubernetesNetworkConfig.serviceIpv4Cidr"));
} finally {
CfnStackWaits.deleteStack(stack);
}
}
private static final String ROLE = "\"RoleArn\": \"arn:aws:iam::000000000000:role/eks-set\", ";
private static final String NETWORK = "\"KubernetesNetworkConfig\": {\"IpFamily\": \"ipv4\","
+ " \"ServiceIpv4Cidr\": \"172.20.0.0/16\"}";
private static String cluster(String role, String team) {
return subjectStack("", "", "AWS::EKS::Cluster", "\"RoleArn\": \"arn:aws:iam::000000000000:role/" + role
+ "\", \"Tags\": [{\"Key\": \"team\", \"Value\": \"" + team + "\"}]");
@@ -1794,6 +1794,19 @@ class EksServiceTest {
.anyMatch(p -> "-1".equals(p.getIpProtocol())
&& p.getUserIdGroupPairs().stream().anyMatch(u -> sgId.equals(u.getGroupId())));
assertTrue(hasSelfEgress, "Security group should have self-referencing outbound egress rule for EFA");
int groupsBefore = ec2Service.describeSecurityGroups("us-east-1", List.of(), List.of(), Map.of()).size();
KubernetesNetworkConfig badFamily = new KubernetesNetworkConfig();
badFamily.setIpFamily("ipv5");
CreateClusterRequest bad = new CreateClusterRequest();
bad.setName("cluster-sg-bad-family");
bad.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
bad.setResourcesVpcConfig(vpcConfig);
bad.setKubernetesNetworkConfig(badFamily);
assertEquals("InvalidParameterException",
assertThrows(AwsException.class, () -> service.createCluster(bad)).getErrorCode());
assertEquals(groupsBefore,
ec2Service.describeSecurityGroups("us-east-1", List.of(), List.of(), Map.of()).size());
}
@Test
@@ -71,7 +71,7 @@ AWS::Cognito::UserPoolResourceServer Identifier,Name,Scopes,UserPoolId
AWS::Cognito::UserPoolUser ClientMetadata,DesiredDeliveryMediums,ForceAliasCreation,MessageAction,UserAttributes,UserPoolId,Username,ValidationData
AWS::Cognito::UserPoolUserToGroupAttachment GroupName,UserPoolId,Username
AWS::Config::ConfigRule Arn,ConfigRuleId Compliance,ConfigRuleName,Description,EvaluationModes,InputParameters,MaximumExecutionFrequency,Scope,Source
AWS::DSQL::Cluster CreationTime,EncryptionDetails,Endpoint,Identifier,PolicyVersion,ResourceArn,Status,VpcEndpoint,VpcEndpointServiceName DeletionProtectionEnabled,KmsEncryptionKey,MultiRegionProperties,PolicyDocument,Tags
AWS::DSQL::Cluster CreationTime,EncryptionDetails,Endpoint,Identifier,PolicyVersion,ResourceArn,Status,VpcEndpoint,VpcEndpointServiceName DeletionProtectionEnabled,KmsEncryptionKey,MetricGroups,MultiRegionProperties,PolicyDocument,Tags
AWS::DynamoDB::GlobalTable Arn,StreamArn,TableId AttributeDefinitions,BillingMode,GlobalSecondaryIndexes,GlobalTableSourceArn,GlobalTableWitnesses,KeySchema,LocalSecondaryIndexes,MultiRegionConsistency,ReadOnDemandThroughputSettings,ReadProvisionedThroughputSettings,Replicas,SSESpecification,StreamSpecification,TableName,TableType,TimeToLiveSpecification,VectorIndexes,WarmThroughput,WriteOnDemandThroughputSettings,WriteProvisionedThroughputSettings
AWS::DynamoDB::Table Arn,StreamArn AttributeDefinitions,BillingMode,ContributorInsightsSpecification,DeletionProtectionEnabled,GlobalSecondaryIndexes,ImportSourceSpecification,KeySchema,KinesisStreamSpecification,LocalSecondaryIndexes,OnDemandThroughput,PointInTimeRecoverySpecification,ProvisionedThroughput,ResourcePolicy,SSESpecification,StreamSpecification,TableClass,TableName,Tags,TimeToLiveSpecification,VectorIndexes,WarmThroughput
AWS::EC2::EIP AllocationId,PublicIp Address,Domain,InstanceId,IpamPoolId,NetworkBorderGroup,PublicIpv4Pool,Tags,TransferAddress
1 AWS::ApiGateway::Account Id CloudWatchRoleArn
71 AWS::Cognito::UserPoolUser ClientMetadata,DesiredDeliveryMediums,ForceAliasCreation,MessageAction,UserAttributes,UserPoolId,Username,ValidationData
72 AWS::Cognito::UserPoolUserToGroupAttachment GroupName,UserPoolId,Username
73 AWS::Config::ConfigRule Arn,ConfigRuleId Compliance,ConfigRuleName,Description,EvaluationModes,InputParameters,MaximumExecutionFrequency,Scope,Source
74 AWS::DSQL::Cluster CreationTime,EncryptionDetails,Endpoint,Identifier,PolicyVersion,ResourceArn,Status,VpcEndpoint,VpcEndpointServiceName DeletionProtectionEnabled,KmsEncryptionKey,MultiRegionProperties,PolicyDocument,Tags DeletionProtectionEnabled,KmsEncryptionKey,MetricGroups,MultiRegionProperties,PolicyDocument,Tags
75 AWS::DynamoDB::GlobalTable Arn,StreamArn,TableId AttributeDefinitions,BillingMode,GlobalSecondaryIndexes,GlobalTableSourceArn,GlobalTableWitnesses,KeySchema,LocalSecondaryIndexes,MultiRegionConsistency,ReadOnDemandThroughputSettings,ReadProvisionedThroughputSettings,Replicas,SSESpecification,StreamSpecification,TableName,TableType,TimeToLiveSpecification,VectorIndexes,WarmThroughput,WriteOnDemandThroughputSettings,WriteProvisionedThroughputSettings
76 AWS::DynamoDB::Table Arn,StreamArn AttributeDefinitions,BillingMode,ContributorInsightsSpecification,DeletionProtectionEnabled,GlobalSecondaryIndexes,ImportSourceSpecification,KeySchema,KinesisStreamSpecification,LocalSecondaryIndexes,OnDemandThroughput,PointInTimeRecoverySpecification,ProvisionedThroughput,ResourcePolicy,SSESpecification,StreamSpecification,TableClass,TableName,Tags,TimeToLiveSpecification,VectorIndexes,WarmThroughput
77 AWS::EC2::EIP AllocationId,PublicIp Address,Domain,InstanceId,IpamPoolId,NetworkBorderGroup,PublicIpv4Pool,Tags,TransferAddress
@@ -156,6 +156,7 @@ AWS::Cognito::UserPoolClient AuthSessionValidity accepted and ignored
AWS::Cognito::UserPoolClient EnablePropagateAdditionalUserContextData accepted and ignored
AWS::Cognito::UserPoolDomain Routing accepted and ignored, as the CognitoCfnProvisioner javadoc records
AWS::Config::ConfigRule Compliance accepted and ignored
AWS::DSQL::Cluster MetricGroups accepted and ignored
AWS::DynamoDB::GlobalTable GlobalTableSourceArn accepted and ignored
AWS::DynamoDB::GlobalTable GlobalTableWitnesses accepted and ignored
AWS::DynamoDB::GlobalTable MultiRegionConsistency accepted and ignored
@@ -296,12 +297,10 @@ AWS::EKS::Cluster CertificateAuthority accepted and ignored
AWS::EKS::Cluster ComputeConfig accepted and ignored
AWS::EKS::Cluster ControlPlaneScalingConfig accepted and ignored
AWS::EKS::Cluster DeletionProtection accepted and ignored
AWS::EKS::Cluster EncryptionConfig accepted and ignored
AWS::EKS::Cluster Force accepted and ignored
AWS::EKS::Cluster KubeApiServerConfig accepted and ignored
AWS::EKS::Cluster KubeControllerManagerConfig accepted and ignored
AWS::EKS::Cluster KubeSchedulerConfig accepted and ignored
AWS::EKS::Cluster KubernetesNetworkConfig accepted and ignored
AWS::EKS::Cluster Logging accepted and ignored
AWS::EKS::Cluster OutpostConfig accepted and ignored
AWS::EKS::Cluster RemoteNetworkConfig accepted and ignored
1 AWS::ApiGateway::ApiKey StageKeys accepted and ignored, as the ApiGatewayApiKeyCfnProvisioner javadoc records
156 AWS::Cognito::UserPoolClient EnablePropagateAdditionalUserContextData accepted and ignored
157 AWS::Cognito::UserPoolDomain Routing accepted and ignored, as the CognitoCfnProvisioner javadoc records
158 AWS::Config::ConfigRule Compliance accepted and ignored
159 AWS::DSQL::Cluster MetricGroups accepted and ignored
160 AWS::DynamoDB::GlobalTable GlobalTableSourceArn accepted and ignored
161 AWS::DynamoDB::GlobalTable GlobalTableWitnesses accepted and ignored
162 AWS::DynamoDB::GlobalTable MultiRegionConsistency accepted and ignored
297 AWS::EKS::Cluster ComputeConfig accepted and ignored
298 AWS::EKS::Cluster ControlPlaneScalingConfig accepted and ignored
299 AWS::EKS::Cluster DeletionProtection accepted and ignored
AWS::EKS::Cluster EncryptionConfig accepted and ignored
300 AWS::EKS::Cluster Force accepted and ignored
301 AWS::EKS::Cluster KubeApiServerConfig accepted and ignored
302 AWS::EKS::Cluster KubeControllerManagerConfig accepted and ignored
303 AWS::EKS::Cluster KubeSchedulerConfig accepted and ignored
AWS::EKS::Cluster KubernetesNetworkConfig accepted and ignored
304 AWS::EKS::Cluster Logging accepted and ignored
305 AWS::EKS::Cluster OutpostConfig accepted and ignored
306 AWS::EKS::Cluster RemoteNetworkConfig accepted and ignored
+1 -1
View File
@@ -51,7 +51,7 @@ FETCH_TIMEOUT_SECONDS = 60
# The resource types whose provisioners read their properties through CfnPropertyTypes.
RESOURCE_TYPES = ["AWS::AutoScaling::LaunchConfiguration", "AWS::DSQL::Cluster", "AWS::EC2::Instance",
"AWS::EC2::LaunchTemplate", "AWS::ECS::TaskDefinition", "AWS::Events::Rule",
"AWS::EC2::LaunchTemplate", "AWS::ECS::TaskDefinition", "AWS::EKS::Cluster", "AWS::Events::Rule",
"AWS::Lambda::Function", "AWS::Lambda::LayerVersion",
"AWS::SES::ConfigurationSetEventDestination"]
+1 -1
View File
@@ -222,7 +222,7 @@ notes:
AWS::CDK::Metadata: accepted; no-op
AWS::Transfer::Server: 'management plane only; Ref returns the server ARN; Arn, ServerId and State attributes supported; AS2 managed egress IPs are not modeled; Domain replacement and IdentityProviderType changes are not supported'
AWS::Transfer::User: 'management plane only; Ref returns the user ARN; Arn attribute supported; Policy and PosixProfile are not supported; a ServerId or UserName change replaces the user'
AWS::EKS::Cluster: 'created with `Name`, `Version`, `RoleArn` and `Tags`, a replacement included; `EncryptionConfig` and `KubernetesNetworkConfig` are accepted and ignored on create; updated in place for `Tags`, keeping tags added outside the stack; a change to `Name`, `RoleArn`, `EncryptionConfig`, `BootstrapSelfManagedAddons`, `OutpostConfig`, `AccessConfig.BootstrapClusterCreatorAdminPermissions`, `KubernetesNetworkConfig.IpFamily` or `KubernetesNetworkConfig.ServiceIpv4Cidr` replaces the cluster, as the registry marks them create-only, and deletes the old one once the update commits; a change to `Version` is accepted with a warning and not applied, as the emulator cannot upgrade a cluster in place'
AWS::EKS::Cluster: 'created with `Name`, `Version`, `RoleArn`, `Tags`, `EncryptionConfig` and `KubernetesNetworkConfig.IpFamily` and `ServiceIpv4Cidr`, a replacement included; a change to `EncryptionConfig`, `IpFamily` or `ServiceIpv4Cidr` replaces the cluster with the new value applied; `ElasticLoadBalancing` and `ServiceIpv6Cidr` are accepted and ignored; updated in place for `Tags`, keeping tags added outside the stack; a change to `Name`, `RoleArn`, `EncryptionConfig`, `BootstrapSelfManagedAddons`, `OutpostConfig`, `AccessConfig.BootstrapClusterCreatorAdminPermissions`, `KubernetesNetworkConfig.IpFamily` or `KubernetesNetworkConfig.ServiceIpv4Cidr` replaces the cluster, as the registry marks them create-only, and deletes the old one once the update commits; a change to `Version` is accepted with a warning and not applied, as the emulator cannot upgrade a cluster in place'
AWS::EKS::Nodegroup: 'created with `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets` and `Tags`; updated in place for `Tags`, keeping tags added outside the stack; a change to `ClusterName`, `NodegroupName`, `NodeRole`, `Subnets`, `AmiType`, `CapacityType`, `DiskSize`, `InstanceTypes` or `RemoteAccess` replaces the nodegroup, as the registry marks them create-only, and deletes the old one once the update commits; `ScalingConfig`, `Labels`, `Taints`, `UpdateConfig`, `Version`, `ReleaseVersion`, `ForceUpdateEnabled`, `LaunchTemplate`, `NodeRepairConfig` and `WarmPoolConfig` are accepted and not applied, whether changed or dropped, with a warning, as the emulator cannot update a nodegroup in place'
AWS::IAM::User: 'template `LoginProfile` and `PermissionsBoundary` are ignored; an API-created login profile is removed on delete'
AWS::KMS::Key: 'created with `Description`, `KeyPolicy`, `KeySpec`, `KeyUsage`, `Origin`, `MultiRegion`, `Enabled`, `EnableKeyRotation` and `Tags`; updated in place for `Description`, `KeyPolicy`, `Enabled`, `EnableKeyRotation` and `Tags`, keeping tags added outside the stack; a template that drops `Description`, `Enabled` or `EnableKeyRotation` clears the description, enables the key and turns rotation off, a dropped `KeyPolicy` keeps the current policy, and one the stack never declared keeps the value set outside it; a rotation change on a key that stays disabled fails, as AWS raises `DisabledException`; a change to `KeySpec`, `KeyUsage`, `Origin` or `MultiRegion` fails the update, as on AWS, and the stack rolls back'