擅长:python、mysql、java
<pre><code> After a bit of tweaking, I was able to fix the issue. Here's the code:
import boto3
# Region your instances are in, e.g. 'us-east-1'
region = 'ap-southeast-1'
#instantiate
client = boto3.client('ec2',region)
ids = []
def lambda_handler(event, context):
NATs = client.describe_nat_gateways(
Filter=[
{
'Name': 'tag:Schedule',
'Values': [
'OfficeHours',
],
},
],
)
for NAT in NATs['NatGateways']:
print('deleted NAT gateways: ' + NAT['NatGatewayId'])
# ids.append(NAT['NatGatewayId'])
# client.delete_nat_gateway(NatGatewayId=ids)
</code></pre>