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
}

feita há um ano1,5 mil visualizações
1 Resposta
0
Resposta aceita

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
ESPECIALISTA
respondido há um ano
profile picture
ESPECIALISTA
avaliado há um ano

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas