dongpiao8821 2019-08-07 09:25
浏览 31

使用aws-sdk终止实例后删除子网时发生DependencyViolation

I control AWS environment using AWS-SDK PHP. When I delete all test environment, the problem has been occurred.

I read the document and I already know DependencyViolation is occurred if I have running instances in target subnet.

So I terminated running instance first, and after that, I tried to delete subnet, but DependencyViolation error is occurred.

I tried these sequences using this code.

<?php
$options = [
    /**
     * information about region, version ..
     */
];
$client = new Ec2Client($options);

$promise = $client->terminateInstancesAsync([
    'InstanceIds' => ['instance-id'],
])->then(function ($result) use ($client) {
    return $client->deleteSubnetAsync([
        'SubnetId' => 'subnet-id',
    ]);
});

I guess the reason of error is "instance is not terminated perfactly but delete subnet action is run".

But I have no idea what I have to do for delete subnet without DependencyViolation.

  • 写回答

0条回答 默认 最新

    报告相同问题?