ImageId requried when launching instance via a Launch Template


The documentation ( claims that I can either specify ImageId directly or via a launch template. But if I specify it in a launch template, the request fails validation. The SDK doesn't even make an outbound connection, just errors out immediately.

How can I make EC2 use the ImageId specified in my launch template?

I'm using the following code to launch an EC2 instance using a launch template:

        $result = $ec2->runInstances([
            'DryRun' => false,
            'LaunchTemplate' => [
                'LaunchTemplateName' => 'test-template',
                'Version' => 1
            'MinCount' => 1,
            'MaxCount' => 1

The template ("test-template" Version 1) has an AMI specified (ami-086b3de06dafe36c5 - Amazon Linux 2). When I run the code above, I immediatelly get the following:

Found 1 error while validating the input provided for the RunInstances operation: [ImageId] is missing and is a required parameter 
질문됨 일 년 전305회 조회
1개 답변

I resolved the issue, for some reason "composer require aws/aws-sdk-php" installed an ancient version of the SDK

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠