until [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) = *"InProgress"* ];
do
echo "Automation is running......"
sleep 1m
done
status=$(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text)
if [ "$status" == "Success" ]; then
echo "Automation $status"
elif [ "$status" == "Failed" -o "$status" == "Cancelled" -o "$status" == "Timed Out" ]; then
echo "Automation $status"
fi
Run Code Online (Sandbox Code Playgroud)
这里循环永远不会退出,它继续打印“自动化正在运行......”即使在自动化已经执行并且状态不是进行中我想要做的是等到状态为“进行中”,打印“自动化是运行......”在屏幕上。完成后,如果失败或成功,我想在屏幕上打印自动化的状态。
我知道在 Cloudformation 中您可以使用 SSM 创建参数,但我真的想知道您是否可以在 lambda 的环境变量中使用 SSM。我知道我可以放置 SSM 路径并在代码中使用 sdk 来获取这些值,但也许有一种方法可以在不从代码中获取值的情况下自动生成。
谢谢
假设我有一个 AWS 账户,其中已经有一些参数存储数据。
有没有办法将这些数据从这个参数存储迁移到另一个:
我更喜欢官方工具来执行此操作,但也欢迎类似于 dynamoDB dump 的工具。
我有以下使用无服务器框架项目的 serverless.yml 文件创建的队列:
resources:
Resources:
myAppSQSQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "my-app-sqs-queue-${opt:stage, self:provider.stage}"
Run Code Online (Sandbox Code Playgroud)
如何获取创建的队列的 URL 并将其作为参数存储在 AWS Systems Manager 中?我需要将其存储在那里,以便该应用程序之外的其他应用程序知道如何访问它。
我想使用 AWS CDK 更新 SSM 参数。
我的用例:在第一个堆栈中,我正在创建 SSM 参数。在第二个堆栈中想要更新(更改)它。我遇到的解决方案之一是使用 lambda,我想避免它。
是通过 CDK 更新现有参数的方法吗?cfn_param.set_value
第一个堆栈:
class ParamSetupStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
ssm.StringParameter( self,
f'PIPELINE-PARAM-1',
parameter_name="parma-1",
string_value="SOME STRING VALUE",
description="Desctiption of ...."
)
Run Code Online (Sandbox Code Playgroud)
第二个堆栈:
class UpdateParamStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
template = cfn_inc.CfnInclude(self, "Template",
template_file="PATH/TO/ParamSetupStack.json",
preserve_logical_ids=False)
cfn_param = template.get_resource("PIPELINE-PARAM-1")
cfn_param.set_value("NEW VALUE")
Run Code Online (Sandbox Code Playgroud) I have a websocket url created by AWS. URL is created by aws ssm start session using .net sdk. Start session method gives me streamUrl, token and session ID. URL is in following format:
wss://ssmmessages.ap-south-1.amazonaws.com/v1/data-channel/sessionidhere?role=publish_subscribe
Run Code Online (Sandbox Code Playgroud)
There is actual session id at placeof "sessionidhere" that I can not share.
I want to open terminal on web using xterm.js. I've read that xterm.js can connect to websocket URL, send messages and receive outputs.
My javascript code is here :
<!doctype html> …Run Code Online (Sandbox Code Playgroud) 我使用 AWS Simple Session Manager 和 AWS CLI 通过 SSH 连接到实例。当我调用 时aws ssm start-session --target INSTANCE_ID,它sh在服务器上启动,而不是bash. 有没有办法自定义实例启动时运行的命令?
我正在尝试在启动会话后获取当前的 aws ssm sessionId。我可以看到当我启动它时它会被打印出来,就像这样
\nStarting session with SessionId: test@test.com-0ftz59d2285d67fb5\nRun Code Online (Sandbox Code Playgroud)\n但我不知道这是从哪里来的。
\n我还可以看到我可以从 ssm-session 工作人员那里获取它,但我正在尝试以更干净的方式获取它:
\n[ssm-user@ip-100-66-11-11 bin]$ sudo systemctl status amazon-ssm-agent\n\xe2\x97\x8f amazon-ssm-agent.service - amazon-ssm-agent\n Loaded: loaded (/usr/lib/systemd/system/amazon-ssm-agent.service; enabled; vendor preset: enabled)\n Active: active (running) since Mon 2021-03-08 09:54:44 UTC; 2h 48min ago\n Main PID: 3092 (amazon-ssm-agen)\n CGroup: /system.slice/amazon-ssm-agent.service\n \xe2\x94\x9c\xe2\x94\x80 875 /usr/bin/ssm-session-worker test@test.com-0ftz59d2285d67fb5 i-0a7bb9a9064ccc96\n \xe2\x94\x9c\xe2\x94\x80 886 bash -l\n \xe2\x94\x9c\xe2\x94\x803092 /usr/bin/amazon-ssm-agent\n \xe2\x94\x94\xe2\x94\x803272 /usr/bin/ssm-agent-worker\nRun Code Online (Sandbox Code Playgroud)\n linux amazon-web-services aws-ssm amazon-linux-2 aws-session-manager
我试图让 IAM 用户只能对特定文档使用 SSM 运行命令。
如果我将以下策略附加到用户,则该用户确实只能AWS-RunShellScript在 EC2 实例上成功执行(这是 AWS 托管的)文档。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeDocument",
"ssm:DescribeDocumentParameters",
"ssm:DescribeDocumentPermission",
"ssm:GetCommandInvocation",
"ssm:GetDocument",
"ssm:ListCommandInvocations",
"ssm:ListCommands",
"ssm:ListDocumentMetadataHistory",
"ssm:ListDocuments",
"ssm:ListDocumentVersions"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ssm:SendCommand",
"Resource": "arn:aws:ssm:us-west-2:999999999999:document/AWS-RunShellScript"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我用我创建的自定义文档 ARN 替换策略中的资源项(例如arn:aws:ssm:us-west-2:999999999999:document/CustomDocument),我会收到“访问被拒绝”的消息
根据需求,我们希望在 SSM 参数存储中存储一个参数,并且应该能够通过 SSM 命令更新参数值。
从初步研究来看,我们可以在 Target EC2 实例上运行 SSM 命令。但是无法找到以目标作为参数存储来运行命令的方法。请帮忙。
aws-ssm ×10
ssm ×2
amazon-ec2 ×1
amazon-iam ×1
amazon-sqs ×1
aws-cdk ×1
aws-cli ×1
aws-lambda ×1
bash ×1
javascript ×1
linux ×1
shell ×1
websocket ×1
xtermjs ×1