UNPKG

3.21 kBTypeScriptView Raw
1import { Construct } from 'constructs';
2import { CfnElement } from './cfn-element';
3import { IResolvable, IResolveContext } from './resolvable';
4export interface CfnConditionProps {
5 /**
6 * The expression that the condition will evaluate.
7 *
8 * @default - None.
9 */
10 readonly expression?: ICfnConditionExpression;
11}
12/**
13 * Represents a CloudFormation condition, for resources which must be conditionally created and
14 * the determination must be made at deploy time.
15 */
16export declare class CfnCondition extends CfnElement implements ICfnConditionExpression, IResolvable {
17 /**
18 * The condition statement.
19 */
20 expression?: ICfnConditionExpression;
21 /**
22 * Build a new condition. The condition must be constructed with a condition token,
23 * that the condition is based on.
24 */
25 constructor(scope: Construct, id: string, props?: CfnConditionProps);
26 /**
27 * @internal
28 */
29 _toCloudFormation(): object;
30 /**
31 * Synthesizes the condition.
32 */
33 resolve(_context: IResolveContext): any;
34}
35/**
36 * Represents a CloudFormation element that can be used within a Condition.
37 *
38 * You can use intrinsic functions, such as ``Fn.conditionIf``,
39 * ``Fn.conditionEquals``, and ``Fn.conditionNot``, to conditionally create
40 * stack resources. These conditions are evaluated based on input parameters
41 * that you declare when you create or update a stack. After you define all your
42 * conditions, you can associate them with resources or resource properties in
43 * the Resources and Outputs sections of a template.
44 *
45 * You define all conditions in the Conditions section of a template except for
46 * ``Fn.conditionIf`` conditions. You can use the ``Fn.conditionIf`` condition
47 * in the metadata attribute, update policy attribute, and property values in
48 * the Resources section and Outputs sections of a template.
49 *
50 * You might use conditions when you want to reuse a template that can create
51 * resources in different contexts, such as a test environment versus a
52 * production environment. In your template, you can add an EnvironmentType
53 * input parameter, which accepts either prod or test as inputs. For the
54 * production environment, you might include Amazon EC2 instances with certain
55 * capabilities; however, for the test environment, you want to use less
56 * capabilities to save costs. With conditions, you can define which resources
57 * are created and how they're configured for each environment type.
58 *
59 * You can use `toString` when you wish to embed a condition expression
60 * in a property value that accepts a `string`. For example:
61 *
62 * ```ts
63 * new sqs.Queue(this, 'MyQueue', {
64 * queueName: Fn.conditionIf('Condition', 'Hello', 'World').toString()
65 * });
66 * ```
67 */
68export interface ICfnConditionExpression extends IResolvable {
69}
70/**
71 * Interface to specify certain functions as Service Catalog rule-specifc.
72 * These functions can only be used in ``Rules`` section of template.
73 */
74export interface ICfnRuleConditionExpression extends ICfnConditionExpression {
75 /**
76 * This field is only needed to defeat TypeScript's structural typing.
77 * It is never used.
78 */
79 readonly disambiguator: boolean;
80}