Creating the Template:
Start by creating a CloudFormation template that includes all the VPC resources. This template should accurately reflect the current state and configuration of the VPC.
Using the CloudFormation Console:
Open the AWS Management Console and navigate to CloudFormation.
Choose "Create stack" and then select "With existing resources (import resources)".
Specifying the Template:
Upload the previously created template or specify the Amazon S3 URL where the template is stored.
Identifying the Resources:
On the "Identify resources" page, provide the identifiers for each VPC resource you wish to import. For example, for anAWS::EC2::VPCresource, use the VPC ID as the identifier.
Creating the Stack:
Complete the stack creation process by providing stack details and reviewing the changes. This will create a change set that includes the import operation.
Executing the Change Set:
Execute the change set to import the resources into the CloudFormation stack, making them managed by CloudFormation.
Verification and Drift Detection:
After the import is complete, run drift detection to ensure the actual configuration matches the template configuration.
This approach allows the company to manage their VPC and other resources via CloudFormation without the need to recreate resources, ensuring a smooth transition to automated infrastructure management.
References
Creating a stack from existing resources - AWS CloudFormation(AWS Documentation).
Generating templates for existing resources - AWS CloudFormation(AWS Documentation).
Bringing existing resources into CloudFormation management(AWS Documentation).