я люблю SSM Runbooks и их способность выполнять логику во время развертываний на основе параметров и путей ветвления, но я отчаянно хочу абстрагировать свои сценарии. Но прилагаемое выполнение скрипта всегда выполняется с этим результатом: < /p>
Сообщение о сбое
Шаг не удастся, когда оно является статусом действия опроса для завершения. Traceback (самый последний вызов последним): AttributeError: Module 'Test' не имеет атрибута «Main» Main, который не найден в предоставленном сценарии. Пожалуйста, обратитесь к Руководству по устранению неполадок автоматизации для получения дополнительной информации о диагностике. ">
Код: Выделить всё
description: A simple SSM runbook that calls a templated script to print and output a message.
schemaVersion: '0.3'
parameters:
Message:
type: String
description: The message to print and output.
default: "Hello from the runbook!"
mainSteps:
- name: ExecuteTemplateScript
action: aws:executeScript
isEnd: true
inputs:
Runtime: python3.10
Handler: test.main # [file].[function] format
InputPayload:
Message: '{{ Message }}'
Script: ''
Attachment: test.py # Name of the attached file
outputs:
- Name: OutputMessage
Selector: $.Payload.OutputMessage
Type: String
files:
test.py:
checksums:
sha256: 590708757b79b9438bf299ee496a121c98cf865899db8fea5d788d0cb616d1f5
< /code>
Я пробовал вариации: < /p>
Handler: test.py.main
handler: test
handler: тест. Main
Handler: Main < /p>
Вот тестовый скрипт.#!/usr/bin/env python3
"""Simple templated script for SSM that prints and outputs a message."""
import json
def process_message(payload: dict) -> dict:
"""Process the input message and return it."""
message = payload.get('Message', 'No message provided')
print(f"Message received: {message}") # Printed to SSM logs
return {'OutputMessage': message}
def main(events, context):
"""Main function for SSM execution."""
# SSM passes InputPayload as 'events'
payload = events
result = process_message(payload)
return result # SSM captures this as output
if __name__ == "__main__":
# For local testing, simulate SSM input
import sys
if not sys.stdin.isatty():
payload = json.load(sys.stdin)
else:
payload = {'Message': 'Hello, world!'}
result = process_message(payload)
print(json.dumps(result))
https://docs.aws.amazon.com/systems-man ... ireference /Api_attachmentssource.html
https://docs.aws.amazon.com/systems-man ... ample.html
https://docs.aws.amazon.com/systems -Manager/Последний/Userguide/Automation-Document-Script-Considerations.html
https://docs.aws.amazon.com/systems-man ... cript.html
Прикреплен скрипт, а контрольная сумма проверяет.
Итак, я пришел на свой последний курорт. Спрашивать экспертов напрямую. Помогите, пожалуйста.
Подробнее здесь: https://stackoverflow.com/questions/794 ... ing-execut