cloudformation.d.ts
1 import { CloudFormation } from 'aws-sdk'; 2 import { StackStatus } from './cloudformation/stack-status'; 3 export declare type Template = { 4 Parameters?: Record<string, TemplateParameter>; 5 [key: string]: any; 6 }; 7 interface TemplateParameter { 8 Type: string; 9 Default?: any; 10 [key: string]: any; 11 } 12 /** 13 * Represents an (existing) Stack in CloudFormation 14 * 15 * Bundle and cache some information that we need during deployment (so we don't have to make 16 * repeated calls to CloudFormation). 17 */ 18 export declare class CloudFormationStack { 19 private readonly cfn; 20 readonly stackName: string; 21 private readonly stack?; 22 static lookup(cfn: CloudFormation, stackName: string): Promise<CloudFormationStack>; 23 /** 24 * Return a copy of the given stack that does not exist 25 * 26 * It's a little silly that it needs arguments to do that, but there we go. 27 */ 28 static doesNotExist(cfn: CloudFormation, stackName: string): CloudFormationStack; 29 /** 30 * From static information (for testing) 31 */ 32 static fromStaticInformation(cfn: CloudFormation, stackName: string, stack: CloudFormation.Stack): CloudFormationStack; 33 private _template; 34 protected constructor(cfn: CloudFormation, stackName: string, stack?: CloudFormation.Stack | undefined); 35 /** 36 * Retrieve the stack's deployed template 37 * 38 * Cached, so will only be retrieved once. Will return an empty 39 * structure if the stack does not exist. 40 */ 41 template(): Promise<Template>; 42 /** 43 * Whether the stack exists 44 */ 45 get exists(): boolean; 46 /** 47 * The stack's ID 48 * 49 * Throws if the stack doesn't exist. 50 */ 51 get stackId(): string; 52 /** 53 * The stack's current outputs 54 * 55 * Empty object if the stack doesn't exist 56 */ 57 get outputs(): Record<string, string>; 58 /** 59 * The stack's status 60 * 61 * Special status NOT_FOUND if the stack does not exist. 62 */ 63 get stackStatus(): StackStatus; 64 /** 65 * The stack's current tags 66 * 67 * Empty list of the stack does not exist 68 */ 69 get tags(): CloudFormation.Tags; 70 /** 71 * Return the names of all current parameters to the stack 72 * 73 * Empty list if the stack does not exist. 74 */ 75 get parameterNames(): string[]; 76 /** 77 * Return the names and values of all current parameters to the stack 78 * 79 * Empty object if the stack does not exist. 80 */ 81 get parameters(): Record<string, string>; 82 /** 83 * Return the termination protection of the stack 84 */ 85 get terminationProtection(): boolean | undefined; 86 private assertExists; 87 } 88 /** 89 * Waits for a ChangeSet to be available for triggering a StackUpdate. 90 * 91 * Will return a changeset that is either ready to be executed or has no changes. 92 * Will throw in other cases. 93 * 94 * @param cfn a CloudFormation client 95 * @param stackName the name of the Stack that the ChangeSet belongs to 96 * @param changeSetName the name of the ChangeSet 97 * 98 * @returns the CloudFormation description of the ChangeSet 99 */ 100 export declare function waitForChangeSet(cfn: CloudFormation, stackName: string, changeSetName: string): Promise<CloudFormation.DescribeChangeSetOutput>; 101 /** 102 * Return true if the given change set has no changes 103 * 104 * This must be determined from the status, not the 'Changes' array on the 105 * object; the latter can be empty because no resources were changed, but if 106 * there are changes to Outputs, the change set can still be executed. 107 */ 108 export declare function changeSetHasNoChanges(description: CloudFormation.DescribeChangeSetOutput): boolean; 109 /** 110 * Waits for a CloudFormation stack to stabilize in a complete/available state 111 * after a delete operation is issued. 112 * 113 * Fails if the stack is in a FAILED state. Will not fail if the stack was 114 * already deleted. 115 * 116 * @param cfn a CloudFormation client 117 * @param stackName the name of the stack to wait for after a delete 118 * 119 * @returns the CloudFormation description of the stabilized stack after the delete attempt 120 */ 121 export declare function waitForStackDelete(cfn: CloudFormation, stackName: string): Promise<CloudFormationStack | undefined>; 122 /** 123 * Waits for a CloudFormation stack to stabilize in a complete/available state 124 * after an update/create operation is issued. 125 * 126 * Fails if the stack is in a FAILED state, ROLLBACK state, or DELETED state. 127 * 128 * @param cfn a CloudFormation client 129 * @param stackName the name of the stack to wait for after an update 130 * 131 * @returns the CloudFormation description of the stabilized stack after the update attempt 132 */ 133 export declare function waitForStackDeploy(cfn: CloudFormation, stackName: string): Promise<CloudFormationStack | undefined>; 134 /** 135 * Wait for a stack to become stable (no longer _IN_PROGRESS), returning it 136 */ 137 export declare function stabilizeStack(cfn: CloudFormation, stackName: string): Promise<CloudFormationStack | undefined>; 138 /** 139 * The set of (formal) parameters that have been declared in a template 140 */ 141 export declare class TemplateParameters { 142 private readonly params; 143 static fromTemplate(template: Template): TemplateParameters; 144 constructor(params: Record<string, TemplateParameter>); 145 /** 146 * Calculate stack parameters to pass from the given desired parameter values 147 * 148 * Will throw if parameters without a Default value or a Previous value are not 149 * supplied. 150 */ 151 supplyAll(updates: Record<string, string | undefined>): ParameterValues; 152 /** 153 * From the template, the given desired values and the current values, calculate the changes to the stack parameters 154 * 155 * Will take into account parameters already set on the template (will emit 156 * 'UsePreviousValue: true' for those unless the value is changed), and will 157 * throw if parameters without a Default value or a Previous value are not 158 * supplied. 159 */ 160 updateExisting(updates: Record<string, string | undefined>, previousValues: Record<string, string>): ParameterValues; 161 } 162 /** 163 * The set of parameters we're going to pass to a Stack 164 */ 165 export declare class ParameterValues { 166 private readonly formalParams; 167 readonly values: Record<string, string>; 168 readonly apiParameters: CloudFormation.Parameter[]; 169 constructor(formalParams: Record<string, TemplateParameter>, updates: Record<string, string | undefined>, previousValues?: Record<string, string>); 170 /** 171 * Whether this set of parameter updates will change the actual stack values 172 */ 173 hasChanges(currentValues: Record<string, string>): boolean; 174 } 175 export {};