I want to list all VPC Name and VPC ID of my AWS account.
I try with this code but its not working
<?php
echo "<br><br>VPC<br>";
$vpcs = $ec2Client->describeVpcAttribute();
foreach ($vpcs as $vpc) {
$vpcName = '';
$vpcid = $vpc['VpcId'];
foreach ($vpc['Tags'] as $tag) {
if ($tag['Key'] == 'Name') {
$vpcName = $tag['Value'];
}
}
echo $vpcName . $vpcid .'<br>';
}
?>
I'm not sure that describeVpcAttribute can list VPC. Can you help me to find the command for this?
Thanks and Regards
Expected: list all VPC Name and VPC ID of my AWS account
Actual results: nothing