何时应使用参数存储来保存配置,何时应使用 AppConfig?例如,如果我必须在运行时更改日志级别,是否应该将其存储在 SSM 或 Appconfig 中?
优缺点都有什么?这两者有什么区别,特别是在具有 lambda 函数的无服务器应用程序的上下文中?
app-config amazon-web-services aws-ssm aws-parameter-store aws-serverless
我正在尝试为 eks 设置 eksctl 但它抛出
"Error: unable to determine AMI to use: error getting AMI from SSM Parameter Store: AccessDeniedException: User: arn:aws:iam:::user/cnc is not authorized to perform: ssm:GetParameter on resource: arn:aws:ssm:us-east-1::parameter/aws/service/eks/optimized-ami/1.18/amazon-linux-2/recommended/image_id".
我正在使用的 IAM 权限策略是
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeParameters"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ssm:GetParameters",
"ssm:GetParametersByPath"
],
"Resource": "arn:aws:ssm:::parameter/*"
}
]
Run Code Online (Sandbox Code Playgroud)
我还尝试使用策略模拟来检查权限,它给了我“隐式拒绝(没有匹配的语句)”
我有一个在 Fargate 上运行的 ECS 任务,我想在 boto3 中运行命令并获取输出。我可以在 awscli 中很好地做到这一点。
\n\xe2\x9e\x9c aws ecs execute-command --cluster cluster1 \\ \n --task abc \\\n --container container1 \\\n --interactive \\\n --command \'echo hi\' \n\nThe Session Manager plugin was installed successfully. Use the AWS CLI to start a session.\n\nStarting session with SessionId: ecs-execute-command-0f913e47ae7801aeb\nhi\n\nExiting session with sessionId: ecs-execute-command-0f913e47ae7801aeb.\nRun Code Online (Sandbox Code Playgroud)\n但我无法弄清楚如何在 boto3 中获得相同的输出。
\n\xe2\x9e\x9c aws ecs execute-command --cluster cluster1 \\ \n --task abc \\\n --container container1 \\\n --interactive \\\n --command \'echo hi\' \n\nThe Session Manager plugin …Run Code Online (Sandbox Code Playgroud) 我按照 AWS 开发者论坛帖子(现已不再可用)中提到的说明进行操作。
政策
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ssm:GetParametersByPath",
"ssm:GetParameters",
"ssm:GetParameter"
],
"Resource": "arn:aws:ssm:eu-central-1:XXXXXXXXXX:parameter/some-root/*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "ssm:DescribeParameters",
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我已将策略附加到角色中的目标账户
当我从源帐户获取参数时,它可以工作,但是我无法从目标帐户访问它们。
C:\Users\my-home>aws ssm get-parameters-by-path --path "/some-root/" --profile aws-acc-src
{
"Parameters": [
{
"Name": "/some-root/dev",
"Type": "SecureString",
"Value": "AQICAHh5z4qygT6rbxBnR/PmJn811vO30kBJNB+JrB1tdKNBeAEHFLSQDpTMsRMc1l0D8lXYAAAAYTBfBgkqhkiG9w0BBwagUjBQAgEAMEsGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM+Qmz5FoNcESEXabnAgEQgB6MdOlb545EPN61QqA50w7rH3sghmNWvxsLPPneHEA=",
"Version": 1,
"LastModifiedDate": "2020-10-06T16:03:32.637000+03:00",
"ARN": "arn:aws:ssm:eu-central-1:XXXXXXXX:parameter/some-root/dev"
}
]
}
aws ssm get-parameters-by-path --path "/some-root/" --with-decryption --profile aws-acc-src
{
"Parameters": [
{
"Name": "/some-root/dev",
"Type": "SecureString",
"Value": …Run Code Online (Sandbox Code Playgroud) 我正在尝试按路径(在 Gitbash 内)查询一些 SSM 参数:
aws --region eu-west-2 --profile some-profile ssm get-parameters-by-path --path /prefix/prefix2
Run Code Online (Sandbox Code Playgroud)
有许多与此前缀匹配的参数,例如
/prefix/prefix2/p1
/prefix/prefix2/p2
...
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
调用 GetParametersByPath 操作时发生错误 (ValidationException):参数不符合参数名称要求。参数名称必须以正斜杠“/”开头。它不能以“aws”或“ssm”为前缀(不区分大小写)。它只能使用字母、数字或以下符号: 。(句点)、-(连字符)、_(下划线)。不允许有特殊字符。所有子路径(如果指定)必须使用正斜杠符号“/”。有效示例:/get/parameters2-/by1./path0_。
如果前缀以“/”结尾,我会得到同样的错误。问题的原因是什么?
以下代码片段:
AWSTemplateFormatVersion: '2010-09-09'
Description: Some CloudFormation template
Resources:
MyResourceName:
Type: AWS::SSM::Parameter
Properties:
Name: myParameterName
Type: String
Value: "somevalue"
Tags:
- Key: firstTagName
Value: firstTagValue
- Key: secondTagName
Value: secondTagValue
Run Code Online (Sandbox Code Playgroud)
在 CloudFormation 中生成以下错误:
我应该如何正确构建 Tags 属性?
更新:\n截至 2023 年 2 月 1 日,我已付款并通过 AWS 开立了票证,这就是回复。请继续等待:
\n在与 Ubuntu 22.04 补丁管理器方面的内部团队联系时,我们获悉,为补丁管理器添加 Ubuntu 22.04 目前是 \xe2\x80\x9cwork-in-progress\xe2\x80\x9d,并且正在进行中路线图将于近期发布。虽然目前还没有确切的预计到达时间,但您预计会在今年第一季度下半年看到此版本。我建议您密切关注我们的 SSM 文档 [1] 和 What\xe2\x80\x99s 新页面 [2] 以获取最新更新。\n对于由此给您带来的不便,我深表歉意。请耐心等待,SSM 团队将致力于在不久的将来发布此版本。
\nSSM 文档 - https://docs.aws.amazon.com/systems-manager/latest/userguide/patch-manager-precessions.html \nWhat\xe2\x80\x99s 新增功能 - https://aws.amazon.com/新的/
\n我已经在升级的 Ubuntu 22.04 主机以及来自官方 AWS - Canonical 映像的干净的新 Ubuntu 22.04 主机上对此进行了测试,并尝试使用 AWS SSM RunPatchBaseLine 修补任一主机失败。
\n命令的标准输出正在报告:root [错误]:加载入口模块时出错。
\n标准错误正在报告:“加载修补有效负载时出错,无法运行命令:退出状态 156
\n/var/log/amazon/ssm/amazon-ssm-agent.log 中失败命令的输出如下所示:
\n"/usr/bin/python3\n/usr/bin/apt-get\nReading package lists...\nBuilding dependency tree...\nReading state information...\npython3-apt is already the newest version (2.3.0ubuntu2).\n0 upgraded, 0 newly installed, 0 …Run Code Online (Sandbox Code Playgroud) 我已设置 CMK(自定义托管密钥)来使用 AWS Systems Session Manager 加密日志组:
首先,在KMS控制台中添加“关键管理员”和“关键用户/角色”的权限。
接下来,CMK 在 AWS Systems Manager 会话管理器首选项中附加到 LogGroup,如下图所示:
错误:
指定的 KMS 密钥不存在或不允许与 LogGroup 'arn:aws:logs:my_region:my_account_id:log-group:/SSM' 一起使用
该密钥必须存在,因为它用于加密会话并且不能正确解密日志组,但它链接到日志组并且用户具有权限。是什么赋予了?
在 AWS CDK 中,您可以创建参数存储条目来存储密码等机密。
但是,您不能将该值留空,也不应该将密钥放入 CDK git 存储库中,那么如何创建该条目呢?
我目前正在做这样的事情:
const paramKey = new cdkSSM.StringParameter(this, 'example-key', {
description: 'Example SSH private key parameter',
parameterName: 'example-key',
stringValue: `???`, /// What goes here?
allowedPattern: '^-----BEGIN RSA PRIVATE KEY-----[^-]*-----END RSA PRIVATE KEY-----$',
});
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我不能保留空白stringValue,否则会收到错误,因为 Parameter Store 不允许空白值。根据要求,它接受的唯一值是 RSA 私钥allowedPattern(这是一种安全措施,旨在防止有人通过 AWS CLI 意外输入无效值)。但我不想将我的私钥放入,因为它不应该是 CDK git 存储库的一部分。我不想使用虚拟密钥,因为这样有人可能会认为已经输入了正确的密钥。
如何在拥有allowedPattern现有参数存储值的情况下部署空白参数存储值?
我想出的唯一解决方法是破解该值以允许另一个令牌,如下所示:
const paramKey = new cdkSSM.StringParameter(this, 'example-key', {
description: 'Example SSH private key parameter',
parameterName: 'example-key',
stringValue: `TODO`,
allowedPattern: '^TODO$|^-----BEGIN RSA PRIVATE …Run Code Online (Sandbox Code Playgroud) 如何从以下命令的以下输出中仅打印 Value 属性的值
aws ssm get-parameter --name "/test/ip/cidr" --profile test
{
"Parameter": {
"Name": "/test/ip/cidr",
"Type": "String",
"Value": "172.18.0.0/20",
"Version": 1,
"LastModifiedDate": 1585251360.78,
"ARN": "arn:aws:ssm:us-east-1:123233:parameter/test/ip/cidr",
"DataType": "text"
}
}
Run Code Online (Sandbox Code Playgroud)
尝试运行以下命令,但打印类似 [{"Value": "172.18.0.0/20"}] 但只想查看 172.18.0.0/20
aws ssm get-parameters --names "/test/ip/cidr" --query "Parameters[*].{Value:Value}" --profile test
[
{
"Value": "172.18.0.0/20"
}
]
Run Code Online (Sandbox Code Playgroud) aws-ssm ×10
amazon-iam ×2
amazon-ecs ×1
amazon-kms ×1
app-config ×1
aws-cdk ×1
boto3 ×1
eksctl ×1
python-3.x ×1
ubuntu ×1