-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::GetIpAddressAndModifyInstanceName.yml
66 lines (66 loc) · 1.92 KB
/
ACS::ECS::GetIpAddressAndModifyInstanceName.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::GetIpAddressAndModifyInstanceName
name-zh-cn: 获取私网IP并修改ECS实例的名称
en: Get the private network IP and modify the name of the ECS instance
zh-cn: 获取私网IP并修改ECS实例的名称
Parameters:
regionId:
Label:
en: RegionId
zh-cn: 地域ID
Type: String
AssociationProperty: ALIYUN::ECS::RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: ECSInstanceId
zh-cn: ECS实例ID
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
instanceNameFormat:
Label:
en: InstanceNameFormat
zh-cn: ECS实例名称的格式
Type: String
Default: Prefix{PrivateIpAddress}Suffix
Tasks:
- Name: GetInstance
Action: ACS::ExecuteAPI
Description:
en: Gets private ip address of ECS instance
zh-cn: 获取ECS实例私网Ip地址
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
InstanceIds:
- '{{ instanceId }}'
Outputs:
IpAddress:
Type: String
ValueSelector: .Instances.Instance[].VpcAttributes.PrivateIpAddress.IpAddress[]
TagValue:
Type: List
ValueSelector: .Instances.Instance[0].Tags.Tag[] | select(.TagKey == "ack.attach.keepInstanceName") | .TagValue
- Name: ModifyInstanceName
Action: ACS::ExecuteApi
When:
Fn::Not:
Fn::Equals:
- '{{ GetInstance.TagValue }}'
- - true
Description:
en: Modifies the name of ECS instance
zh-cn: 修改ECS实例名称
Properties:
Service: ECS
API: ModifyInstanceAttribute
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ instanceId }}'
InstanceName:
Fn::Replace:
- '{PrivateIpAddress}': '{{ GetInstance.IpAddress }}'
- '{{ instanceNameFormat }}'