가상 파라미터는 AWS CloudFormation에서 사전 정의된 파라미터입니다. 따라서 템플릿에서 가상 파라미터를 선언할 필요가 없습니다. 가상 파라미터는 Ref
함수의 인수로 파라미터를 사용하는 것과 동일한 방식으로 사용합니다.
예제
다음 코드 조각에서는 AWS::Region
가상 파라미터의 값을 출력 값에 할당합니다.
JSON
"Outputs" : {
"MyStacksRegion" : { "Value" : { "Ref" : "AWS::Region" } }
}
YAML
Outputs:
MyStacksRegion:
Value: !Ref "AWS::Region"
AWS::AccountId
스택이 생성되는 계정의 AWS 계정 ID를 반환합니다(예: 123456789012
).
AWS::NotificationARNs
현재 스택에 대한 알림 Amazon 리소스 이름(ARN) 목록을 반환합니다.
목록에서 단일 ARN을 가져오려면 Fn::Select를 사용합니다.
JSON
"myASGrpOne" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Version" : "2009-05-15",
"Properties" : {
"AvailabilityZones" : [ "us-east-1a" ],
"LaunchConfigurationName" : { "Ref" : "MyLaunchConfiguration" },
"MinSize" : "0",
"MaxSize" : "0",
"NotificationConfigurations" : [{
"TopicARN" : { "Fn::Select" : [ "0", { "Ref" : "AWS::NotificationARNs" } ] },
"NotificationTypes" : [ "autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_LAUNCH_ERROR" ]
}]
}
}
YAML
myASGrpOne:
Type: AWS::AutoScaling::AutoScalingGroup
Version: '2009-05-15'
Properties:
AvailabilityZones:
- "us-east-1a"
LaunchConfigurationName:
Ref: MyLaunchConfiguration
MinSize: '0'
MaxSize: '0'
NotificationConfigurations:
- TopicARN:
Fn::Select:
- '0'
- Ref: AWS::NotificationARNs
NotificationTypes:
- autoscaling:EC2_INSTANCE_LAUNCH
- autoscaling:EC2_INSTANCE_LAUNCH_ERROR
AWS::NoValue
Fn::If
내장 함수에 반환 값으로 지정된 경우 해당 리소스 속성을 제거합니다.
예를 들어, 스냅샷 ID가 제공된 경우에만 Amazon RDS DB 인스턴스에 대한 스냅샷을 사용하려는 경우 AWS::NoValue
파라미터를 사용할 수 있습니다. UseDBSnapshot
조건이 true로 평가되면 CloudFormation에서는 DBSnapshotIdentifier
속성에 대한 DBSnapshotName
파라미터 값을 사용합니다. 조건이 false로 평가되면 CloudFormation이 DBSnapshotIdentifier
속성을 제거합니다.
JSON
"MyDB" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"AllocatedStorage" : "5",
"DBInstanceClass" : "db.t2.small",
"Engine" : "MySQL",
"EngineVersion" : "5.5",
"MasterUsername" : { "Ref" : "DBUser" },
"MasterUserPassword" : { "Ref" : "DBPassword" },
"DBParameterGroupName" : { "Ref" : "MyRDSParamGroup" },
"DBSnapshotIdentifier" : {
"Fn::If" : [
"UseDBSnapshot",
{"Ref" : "DBSnapshotName"},
{"Ref" : "AWS::NoValue"}
]
}
}
}
YAML
MyDB:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: '5'
DBInstanceClass: db.t2.small
Engine: MySQL
EngineVersion: '5.5'
MasterUsername:
Ref: DBUser
MasterUserPassword:
Ref: DBPassword
DBParameterGroupName:
Ref: MyRDSParamGroup
DBSnapshotIdentifier:
Fn::If:
- UseDBSnapshot
- Ref: DBSnapshotName
- Ref: AWS::NoValue
AWS::Partition
리소스가 있는 파티션을 반환합니다. 표준 AWS 리전에서 파티션은 aws
입니다. 다른 파티션에 있는 리소스의 경우 파티션은 aws-
partitionname
입니다. 예를 들어 중국(베이징 및 닝샤) 리전에 있는 리소스에 대한 파티션은 aws-cn
이고 AWS GovCloud (US-West) 리전에 있는 리소스에 대한 파티션은 aws-us-gov
입니다.
AWS::Region
포괄 리소스를 생성하는 리전을 나타내는 문자열을 반환합니다(예: us-west-2
).
AWS::StackId
aws cloudformation create-stack
명령으로 지정된 스택의 ID를 반환합니다(예: arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123
).
AWS::StackName
aws cloudformation create-stack
명령으로 지정된 스택의 이름을 반환합니다(예: teststack
).
AWS::URLSuffix
도메인에 대한 접미사를 반환합니다. 접미사는 일반적으로 amazonaws.com
이지만 리전에 따라 다를 수 있습니다. 예를 들어 중국(베이징) 리전의 접미사는 amazonaws.com.cn
입니다.