5

Could you possibly let me know how I can check when the VPC has been created? Or how to check in cloudtrail who created vpc via cli?

I've tried to use cloudtrail and search in event name for CreateVpc but I was not able to find anything.

netmat
  • 61
  • 2
  • 4
  • 2
    I'm surprised it's not a property of the VPC. CloudTrail queries searched with Athena is probably how I'd approach this. – Tim Feb 18 '21 at 07:51
  • 2
    If the VPC was created before CloudTfail or Config were enabled then there's no way to get the date. – Putnik Feb 18 '21 at 16:03

1 Answers1

2

If you happened to create NAT Gateways at the same time, I know many people do, you would be able to get the CreateTime from that: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-nat-gateways.html

Using aws ec2 describe-nat-gateways, for example:

{
  "NatGateways": [
    {
      "NatGatewayAddresses": [
        {
          "PublicIp": "198.11.222.333",
          "NetworkInterfaceId": "eni-9dec76cd",
          "AllocationId": "eipalloc-89c620ec",
          "PrivateIp": "10.0.0.149"
        }
      ],
      "VpcId": "vpc-1a2b3c4d",
      "Tags": [
              {
                  "Value": "IT",
                  "Key": "Department"
              }
      ],
      "State": "available",
      "NatGatewayId": "nat-05dba92075d71c408",
      "SubnetId": "subnet-847e4dc2",
      "CreateTime": "2015-12-01T12:26:55.983Z"
    },
    {
      "NatGatewayAddresses": [
        {
          "PublicIp": "1.2.3.12",
          "NetworkInterfaceId": "eni-71ec7621",
          "AllocationId": "eipalloc-5d42583f",
          "PrivateIp": "10.0.0.77"
        }
      ],
      "VpcId": "vpc-11aa22bb",
      "Tags": [
              {
                  "Value": "Finance",
                  "Key": "Department"
              }
      ],
      "State": "available",
      "NatGatewayId": "nat-0a93acc57881d4199",
      "SubnetId": "subnet-7f7e4d39",
      "CreateTime": "2015-12-01T12:09:22.040Z"
    }
  ]
}
TryTryAgain
  • 1,152
  • 5
  • 22
  • 41
  • `aws ec2 describe-vpcs` command does not show the creation date – Eugen Konkov Jul 28 '23 at 19:03
  • 1
    @EugenKonkov I know it doesn't, unfortunately... that's why I suggest using `aws ec2 describe-nat-gateways` if you actually have NAT Gateways available and they were created when the VPC was created. – TryTryAgain Aug 07 '23 at 17:57