Last active
August 1, 2021 14:08
-
-
Save kawaz/7cda0c968cd9e8e9a05a87b70edd6b96 to your computer and use it in GitHub Desktop.
[CUE](https://cuelang.org/) の練習で CloudFormation のテンプレート定義を適当に書き下してみた。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cfn | |
Template:: close({ | |
AWSTemplateFormatVersion?: "2010-09-09" | |
Transform?: string | [...string] | |
Description?: string | |
Metadata?: [string]: Value | |
Parameters?: [string]: Parameter | |
Mappings?: [string]: [string]: [string]: _ | |
Conditions?: [string]: Condition | |
Resources: [string]: Resource | |
Outputs?: [string]: Output | |
}) | |
Parameter:: {} //TODO | |
Condition:: {} //TODO | |
Mapping:: {} //TODO | |
Resource:: { | |
Type: string | |
DependsOn?: string | [...string] | |
DeletionPolicy?: "Delete" | "Retain" | "Snapshot" | |
UpdateReplacePolicy?: "Delete" | "Retain" | "Snapshot" | |
CreationPolicy?: close({ | |
AutoScalingCreationPolicy?: close({ MinSuccessfulInstancesPercent: uint & <=100 | *100 }) | |
ResourceSignal?: close({ | |
Count?: uint | *1 | |
Timeout?: =~#"^PT(\d+H)?(\d+M)?(\d+S)?$"# | *"PT5M" | |
}) | |
}) | |
UpdatePolicy?: | |
(Type == "AWS::AutoScaling::AutoScalingGroup" & { | |
AutoScalingReplacingUpdate?: close({ WillReplace?: bool }) | |
AutoScalingRollingUpdate?: close({ | |
AutoScalingRollingUpdate?: uint & >=1 | *1 | |
MinInstancesInService?: uint | *0 | |
MinSuccessfulInstancesPercent?: uint & <=100 | *100 | |
PauseTime?: =~#"^PT(\d+H)?(\d+M)?(\d+S)?$"# | *"PT0S" | *"PT5M" & WaitOnResourceSignals == true | |
SuspendProcesses?: [...("Launch"|"Terminate"|"HealthCheck"|"ReplaceUnhealthy"|"AZRebalance"|"AlarmNotification"|"ScheduledActions"|"AddToLoadBalancer")] & [_, ...] | |
WaitOnResourceSignals?: bool | *false | |
if MinSuccessfulInstancesPercent != null | PauseTime != null | WaitOnResourceSignals != null { MinSuccessfulInstancesPercent:_, PauseTime:_, WaitOnResourceSignals:_ } | |
}) | |
AutoScalingScheduledAction?: close({IgnoreUnmodifiedGroupSizeProperties: bool|*true}) | |
}) | | |
(Type == "AWS::Lambda::Alias" & {CodeDeployLambdaAliasUpdate: {AfterAllowTrafficHook?: String, ApplicationName: String, BeforeAllowTrafficHook?: String, DeploymentGroupName: String}}) | | |
(Type == "AWS::ElastiCache::ReplicationGroup" & {UseOnlineResharding: Bool}) | |
MetaData?: { | |
[string]: Value | |
"AWS::CloudFormation::Authentication"?: [string]: | |
close({ type: "basic", username: String, password: String, uris: [...String] }) | | |
close({ type: "S3", accessKeyId: String, secretKey: String, buckets: [...String], roleName: String }) | |
"AWS::CloudFormation::Init"?: _ //TODO | |
"AWS::CloudFormation::Interface"?: close({ | |
ParameterGroups?: [...close({ Label: Label, Parameters: [...Value] })] | |
ParameterLabels?: [string]: Label | |
Label:: close({default?: string}) | |
}) | |
} | |
} | |
Output:: close({ | |
Description?: string | |
Value: Value | |
Condition?: Value | |
Export?: close({Name: Value}) | |
}) | |
Value:: null | bool | number | string | [...Value] | { [string]: Value } | Ref | |
Bool:: bool | "true" | "false" | Ref | BoolFn | |
String:: string | Ref | StringFn | |
Number:: number | Ref | NumberFn | |
Ref:: close({Ref: !="^AWS::" & String}) | PseudoParameter | |
PseudoParameter:: close({Ref: "AWS::AccountId" | "AWS::Region" | "AWS::NotificationARNs" | "AWS::NoValue" | "AWS::Partition" | "AWS::Region" | "AWS::StackId" | "AWS::StackName" | "AWS::URLSuffix"}) | |
xBuiltinFn:: close({[=~"^Fn::"]: _}) | |
BuiltinFn:: // https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html | |
{"Fn::Base64": String} | | |
{"Fn::Cidr": [String, Numner, Number]} | | |
{"Fn::FindInMap": [String, String, String]} | | |
{"Fn::GetAtt": [(string|Ref), string]} | | |
{"Fn::GetAZs": String | "" | {Ref: "AWS::Region"}} | | |
{"Fn::ImportValue": String} | | |
{"Fn::Join": [String, [...String]]} | | |
{"Fn::Select": [Number, Value]} | | |
{"Fn::Split": [String, String]} | | |
{"Fn::Sub": String | [String, {[string]: Value}]} | | |
{"Fn::Transform": close({Name: String, Parameters?: [string]: Value}) } | | |
BoolFn | Ref | |
BoolFn:: close({[=~"^Fn::"]: _}) | |
BoolFn:: // https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html | |
{"Fn::And": [...(Bool|{Condition:string})]} | | |
{"Fn::Equals": [Value, Value]} | | |
{"Fn::If": [string, Value, Value]} | | |
{"Fn::Not": [Bool]} | | |
{"Fn::Or": [...(Bool|{Condition:string})]} | |
StringFn=BuiltinFn //TODO | |
NumberFn=BuiltinFn //TODO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment