Using Terraform to create a systems manager document

0

Hi I need some help I am trying to create a systems manager document using terraform this is what I have but I get Yaml is not will formatted errors appreciate help:

resource "aws_ssm_association" "testa" { name = aws_ssm_document.test.name schedule_expression = "cron(0 0 0 ? * * *)" targets { key = "tag:run_ssm_document" values = ["yes"] } }

resource "aws_ssm_document" "test" { name = "test" document_format = "YAML" document_type = "Automation"

content =<<DOC { schemaVersion:"0.3", assumeRole: parameters: {},

mainSteps: [ { -name:runtestpose action: "aws:executeScript" inputs: Runtime: python3.6 Handler: script_handler Script:| def script_handler(events, context): import boto3 ec2 = boto3.client('ec2')
print("hello world") } } ] DOC
}

preguntada hace un año1,5 mil visualizaciones
1 Respuesta
0
Respuesta aceptada

Hello.

Since "document_format" is set to YAML, I think an error will occur if "mainSteps" is not written in YAML.
https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-schemas-features.html#automation-doc-syntax-examples
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_document

resource "aws_ssm_association" "testa" { name = aws_ssm_document.test.name schedule_expression = "cron(0 0 0 ? * * *)" targets { key = "tag:run_ssm_document" values = ["yes"] } }

resource "aws_ssm_document" "test" {
    name = "test"
    document_format = "YAML"
    document_type = "Automation"

    content =<<DOC
schemaVersion:"0.3"
assumeRole: parameters: {}
mainSteps:
     - name:runtestpose
       action: "aws:executeScript" 
       inputs: 
         Runtime: python3.6
         Handler: script_handler
         Script: | - 
           def script_handler(events, context): 
             import boto3 
             ec2 = boto3.client('ec2')
             print("hello world") 
DOC
}
profile picture
EXPERTO
respondido hace un año
profile picture
EXPERTO
revisado hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas