Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Cross account Cloudformation macro

I am trying to create a cross account macro which will will be used in Cloudformation. According to the doc - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html we have to create macros in different accounts but the underlying lambda can be re-used by making it cross account accessible.

Sample Example:

Account A

In Account_A(2 22222222222) I have created a lambda function "TestMacroFunction" which is used in the macro.

I have added following trust policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "lambda.amazonaws.com",
        "AWS": "arn:aws:iam::483427547108:role/service-role/TestLambdaInvoker-role-lu7aa94t"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

Account B

In Account_B(111111111111) which will have a cloudformation stack for Macro and another stack which will use the macro.

CFN for macro

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
    "SageMakerEndpointAlarmsMacro": {
      "Type": "AWS::CloudFormation::Macro",
      "Properties": {
        "Name": "ExternalMacro",
        "FunctionName": "arn:aws:lambda:us-east-2:111111111111:function:TestMacroFunction",
        "LogGroupName": "MacroLogGroup"
      }
    }
  }
}

CFN for Stack using macro:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Transform": [
    "ExternalMacro"
  ],
  "Resources": {
    "TestBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {}
    }
  }
}

While running the CFN stack I provide a Role which has following policy attached:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Resource": "arn:aws:lambda:us-east-2:111111111111:function:TestMacroFunction",
            "Effect": "Allow"
        }
    ]
}

But still I am getting error in cloudformation. The transform in not executing. Also the lambda function is not getting invoked.

Has anyone created a lambda which is used by macros in other account?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda