Skip to content

Commit

Permalink
deal with boolean properly in resource config
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed May 27, 2020
1 parent a1e707d commit 236cb71
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,18 @@ export class ClusterResourceHandler extends ResourceHandler {
}

if (updates.updateLogging || updates.updateAccess) {
const updateResponse = await this.eks.updateClusterConfig({
const config: aws.EKS.UpdateClusterConfigRequest = {
name: this.clusterName,
logging: this.newProps.logging,
resourcesVpcConfig: this.newProps.resourcesVpcConfig,
});
};
if (updates.updateAccess) {
config.resourcesVpcConfig = {
endpointPrivateAccess: this.newProps.resourcesVpcConfig.endpointPrivateAccess,
endpointPublicAccess: this.newProps.resourcesVpcConfig.endpointPublicAccess,
publicAccessCidrs: this.newProps.resourcesVpcConfig.publicAccessCidrs,
}
}
const updateResponse = await this.eks.updateClusterConfig(config);

return { EksUpdateId: updateResponse.update?.id };
}
Expand Down
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ export interface EksUpdateId {

export type ResourceEvent = AWSLambda.CloudFormationCustomResourceEvent & EksUpdateId;


/**
* Decodes encoded true/false values
*/
function decodeBooleans(object: object) {
return JSON.parse(JSON.stringify(object), (_k, v) => {
switch (v) {
case 'TRUE:BOOLEAN':
return true;
case 'FALSE:BOOLEAN':
return false;
default:
return v;
}
});
}

export abstract class ResourceHandler {
protected readonly requestId: string;
protected readonly logicalResourceId: string;
Expand All @@ -33,6 +50,10 @@ export abstract class ResourceHandler {
throw new Error('AssumeRoleArn must be provided');
}

if (event.ResourceProperties.Config) {
this.event.ResourceProperties.Config = decodeBooleans(event.ResourceProperties.Config);
}

eks.configureAssumeRole({
RoleArn: roleToAssume,
RoleSessionName: `AWSCDK.EKSCluster.${this.requestType}.${this.requestId}`,
Expand Down

0 comments on commit 236cb71

Please sign in to comment.