Amazon web services 可以在AWS中标记SSH密钥对吗?
表示密钥对可以有标记,但不可能按标记或标记密钥筛选密钥。此外,密钥对没有特定的类型ID,如Amazon web services 可以在AWS中标记SSH密钥对吗?,amazon-web-services,amazon-ec2,tags,key-pair,Amazon Web Services,Amazon Ec2,Tags,Key Pair,表示密钥对可以有标记,但不可能按标记或标记密钥筛选密钥。此外,密钥对没有特定的类型ID,如i-*、vol-*等,因此也不可能使用CreateTags进行标记。通过网络创建也不可能。 所有这一切看起来都很混乱,因为没有办法创建标记,但它可以被标记uhm…我个人没有尝试过,但在AWS CLI中使用description key pairs,应该可以为您提供密钥id { "KeyFingerprint": "6d:5c:e0:19:de:.........", "KeyMaterial
i-*
、vol-*
等,因此也不可能使用CreateTags进行标记。通过网络创建也不可能。
所有这一切看起来都很混乱,因为没有办法创建标记,但它可以被标记uhm…我个人没有尝试过,但在AWS CLI中使用
description key pairs
,应该可以为您提供密钥id
{
"KeyFingerprint": "6d:5c:e0:19:de:.........",
"KeyMaterial": "......",
"KeyName": "my-test-key",
"KeyPairId": "key-0ab4ff01abc9999e"
}
但是,我发现标记密钥id的唯一方法是使用AWS CLI生成密钥id并查看输出
如果使用简单的命令:
aws ec2 create-key-pair --key-name my-test-key --profile my-profile
然后输出具有密钥id
{
"KeyFingerprint": "6d:5c:e0:19:de:.........",
"KeyMaterial": "......",
"KeyName": "my-test-key",
"KeyPairId": "key-0ab4ff01abc9999e"
}
然后,您可以使用您已经知道的创建标记来标记资源。1。Ids
从适用于Linux的aws cli 2.2.11版开始,我发现密钥具有KeyPairIds…资源ID
2。关于标记键
是的,您可以使用ec2创建标记。使用创建密钥对是很有问题的
aws ec2创建标记帮助是以下命令的参考
常规命令和参数
aws ec2 create-tags \
--resources "string" "string" --tags Key=string,Value=string ...
示例。
首先描述我的密钥以获取资源ID…密钥对ID
aws ec2 describe-key-pairs --profile-name adrianteri-devops
输出
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops",
"Tags": []
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops",
"Tags": []
}
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": []
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": [
{
"Key": "Project",
"Value": "Test"
},
{
"Key": "CreatedBy",
"Value": "TestBot"
},
{
"Key": "Billing",
"Value": "QualityAssurance"
}
]
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
}
]
}
(END)
现在创建标签…
aws ec2 create-tags --resources key-044180521638ac88d key-0c010638921030fdc --tags Key=Project,Value=adrianteri-com Key=CreatedBy,Value=adrianteri --profile adrianteri-devops
测试密钥对具有不同的标记
aws ec2 create-tags --resources key-0d047bbc242c7e0a2 --tags Key=Project,Value=Test Key=CreatedBy,Value=TestBot Key=Billing,Value=QualityAssuarance --profile adrianteri-live-devops
再次描述密钥对的结果:
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
},
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": [
{
"Key": "Project",
"Value": "Test"
},
{
"Key": "CreatedBy",
"Value": "TestBot"
},
{
"Key": "Billing",
"Value": "QualityAssuarance"
}
]
}
]
}
(END)
3。按标签筛选关键点
也可以使用--过滤器标记键和标记:
标记键
aws ec2 describe-key-pairs --filters Name=tag-key,Values=Billing --profile adrianteri-devops
输出
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops",
"Tags": []
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops",
"Tags": []
}
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": []
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": [
{
"Key": "Project",
"Value": "Test"
},
{
"Key": "CreatedBy",
"Value": "TestBot"
},
{
"Key": "Billing",
"Value": "QualityAssurance"
}
]
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
}
]
}
(END)
标签:
输出
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops",
"Tags": []
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops",
"Tags": []
}
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": []
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-0d047bbc242c7e0a2",
"KeyFingerprint": "69:2d:6f:6f:af:cf:45:d3:a9:d5:e7:63:b3:54:8b:85:32:67:9e:a0",
"KeyName": "test-keypair",
"Tags": [
{
"Key": "Project",
"Value": "Test"
},
{
"Key": "CreatedBy",
"Value": "TestBot"
},
{
"Key": "Billing",
"Value": "QualityAssurance"
}
]
}
]
}
(END)
{
"KeyPairs": [
{
"KeyPairId": "key-044180521638ac88d",
"KeyFingerprint": "69:b4:71:46:65:40:37:59:7c:8c:5f:fa:c6:46:5a:e4:12:e0:46:54",
"KeyName": "adrianteri-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
},
{
"KeyPairId": "key-0c010638921030fdc",
"KeyFingerprint": "21:6b:f8:05:bc:96:13:8d:ba:75:41:bb:5b:43:15:f7:9c:b0:a3:a4",
"KeyName": "ansible-devops-keypair",
"Tags": [
{
"Key": "Project",
"Value": "adrianteri-com"
},
{
"Key": "CreatedBy",
"Value": "adrianteri"
}
]
}
]
}
(END)
大多数“较新”的服务都有向资源添加标签API,它接受资源ARN,例如ARN:aws:ec2:us-east-1:123456789012:keypair/my keyname
,但ec2api在这里似乎是个例外。我猜只是因为这是AWS最早/最老的东西之一。有人在这个周末更新了KeyPairInfo的文档。现在一切都清楚了。感谢沉默的AWS员工