image builder distribution LaunchTemplateConfigurations to other region

0

hi could you give me an example of config about image builder distribution LaunchTemplateConfigurations to other region? i always get error: Account "source accoutId" must be provided as a target account in region 'target region' to use launchTemplateConfigurations. here is the config:

Distribution:
    Type: 'AWS::ImageBuilder::DistributionConfiguration'
    Properties:
      Name: 'CUDA 2204 Distribution'
      Description: 'Distribution for CUDA 22.04.'
      Distributions:
        - Region: !Ref 'AWS::Region'     # it works in same region!!!
          AmiDistributionConfiguration:
            Name:
              !Sub 'CUDA2204 - ${GetVersion.version} {{imagebuilder:buildDate}}'
            Description: 'CUDA image based on Ubuntu 22.04'
            AmiTags:
              ImageBuilder: 'CUDA2204'
              Owner: !Ref 'Owner'
              Version: !GetAtt 'GetVersion.version'
            TargetAccountIds:
              - xxxxxxxx   # # AwsNetworkModelsDev01 
          LaunchTemplateConfigurations:
            - AccountId: !Sub '${AWS::AccountId}'
              LaunchTemplateId: '{{resolve:ssm:/LaunchTemplate/CUDA2204/Id}}'
              SetDefaultVersion: true
            - AccountId: xxxxxxxxxx              # (accout id in same region)
              LaunchTemplateId: xxxxxx       #(launchtemplate in target account)
              SetDefaultVersion: true
        - Region: xxxxxxx. (another region)
          AmiDistributionConfiguration:
            Name:
              !Sub 'CUDA2204 - ${GetVersion.version} {{imagebuilder:buildDate}}'
            Description: 'CUDA image based on Ubuntu 22.04'
            AmiTags:
              ImageBuilder: 'CUDA2204'
              Owner: !Ref 'Owner'
              Version: !GetAtt 'GetVersion.version'
            TargetAccountIds:
              - xxxxxxx      # AwsNetworkModelsDev02 
          LaunchTemplateConfigurations
            - AccountId: xxxxxxxxx           #(target account in another region)
              LaunchTemplateId: xxxxxxxx        #(launchtemplate in target account in another region)
              SetDefaultVersion: true
echzhai
gefragt vor 6 Monaten218 Aufrufe
1 Antwort
0

I was able to replicate a similar error message to yours by using below-mentioned template.

AWSTemplateFormatVersion: 2010-09-09
Description: Testing Distributor
Parameters: 
  TargetAccountId:
    Type: String
Resources:
  Distribution:
    Type: 'AWS::ImageBuilder::DistributionConfiguration'
    Properties:
      Name: Multi Region Distributor
      Description: Multi Region Distributor
      Distributions:
        - Region: us-east-1
          AmiDistributionConfiguration:
            Name: 'AMI-us-east-1 {{ imagebuilder:buildDate }}'
            Description: AMI-us-east-1
            TargetAccountIds:
              - !Ref AWS::AccountId
          LaunchTemplateConfigurations:
            - AccountId: !Ref AWS::AccountId
              LaunchTemplateId: lt-xxxxxxxxxxxxx
              SetDefaultVersion: true
        - Region: us-east-2
          AmiDistributionConfiguration:
            Name: 'AMI-us-east-2 {{ imagebuilder:buildDate }}'
            Description: AMI-us-east-2
            TargetAccountIds:
              - !Ref TargetAccountId
              # - !Ref AWS::AccountId
          LaunchTemplateConfigurations:
            - AccountId: !Ref TargetAccountId
              LaunchTemplateId: lt-xxxxxxxxxxxxx
              SetDefaultVersion: true

In order to resolve the issue, I simply added the source account id in the TargetAccountIds for the us-east-2 region configuration as well and retried the stack creation.

AWSTemplateFormatVersion: 2010-09-09
Description: Testing Distributor
Parameters: 
  TargetAccountId:
    Type: String
Resources:
  Distribution:
    Type: 'AWS::ImageBuilder::DistributionConfiguration'
    Properties:
      Name: Multi Region Distributor
      Description: Multi Region Distributor
      Distributions:
        - Region: us-east-1
          AmiDistributionConfiguration:
            Name: 'AMI-us-east-1 {{ imagebuilder:buildDate }}'
            Description: AMI-us-east-1
            TargetAccountIds:
              - !Ref AWS::AccountId
          LaunchTemplateConfigurations:
            - AccountId: !Ref AWS::AccountId
              LaunchTemplateId: lt-xxxxxxxxxxxxx
              SetDefaultVersion: true
        - Region: us-east-2
          AmiDistributionConfiguration:
            Name: 'AMI-us-east-2 {{ imagebuilder:buildDate }}'
            Description: AMI-us-east-2
            TargetAccountIds:
              - !Ref TargetAccountId
              - !Ref AWS::AccountId
          LaunchTemplateConfigurations:
            - AccountId: !Ref TargetAccountId
              LaunchTemplateId: lt-xxxxxxxxxxxxx
              SetDefaultVersion: true

With this template, I was able to create the stack successfully. Please refer to the above-mentioned template as an example and if needed any troubleshooting on your stack, you can reach out to us by creating a support case from the Support Center.

AWS
SUPPORT-TECHNIKER
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen