How aws-samples/aws-account-vending-machine works
Project Type & Purpose
• This is an AWS infrastructure-automation solution (Account Vending Machine) built on AWS Service Catalog, CloudFormation, AWS Lambda, and AWS Organizations APIs.
• It streamlines on-demand creation and bootstrapping of new AWS accounts (Commercial and GovCloud) with a defined security and service-catalog baseline.
File Structure & README
• Top‐level directories:
• govcloud/ – CloudFormation templates and Lambda zips for AWS GovCloud account vending.
• resources/ – Commercial-side templates, Lambda code (AccountCreationLambda.py + dependencies), CloudFormation YAMLs, and images.
• Key artifacts:
• AccountCreationLambda.zip & AccountCreationLambdaSetup-cfn.yaml – Lambda for account creation.
• accountbuilder.yml, Accountbaseline.yml – Service Catalog product and baseline templates.
Main Components
a. End User / Admin (via AWS Console or Service Catalog API)
b. AWS Service Catalog – Defines the “Account Vending Machine” product.
c. Amazon S3 – Stores CloudFormation templates and Lambda deployment packages.
d. CloudFormation (Master Account)
• Stack to deploy the Service Catalog product and set up IAM roles.
e. AccountCreation Lambda (Master)
• Orchestrates account creation, OU creation, role assumption, baseline deployment.
f. AWS Organizations – CreateAccount API, OU hierarchy management.
g. IAM – OrganizationAccountAccessRole in new account; IAM user/group for Service Catalog access.
h. CloudFormation (New Account) – Deploy baseline resources (delete default VPCs, create Service Catalog portfolio & products).
i. Vended AWS Accounts – Commercial and GovCloud variants.
Relationships & Data Flow
1. End-user launches AVM product in Service Catalog → triggers CloudFormation stack.
2. CloudFormation stack in Master Account deploys:
• Service Catalog product definition (accountbuilder.yml)
• IAM roles & permissions
• AccountCreation Lambda function (zipped from S3)
3. Service Catalog “LAUNCH PRODUCT” → invokes AccountCreation Lambda.
4. Lambda calls AWS Organizations: CreateAccount → returns new account ID.
5. Lambda (if specified) CreateOrganizationalUnit & MoveAccount under OU.
6. Lambda assumes OrganizationAccountAccessRole in new account.
7. Within new account, Lambda (via assumed role) triggers CloudFormation templates stored in S3:
– Accountbaseline.yml (delete default VPCs, set up Service Catalog portfolio/products)
8. Lambda creates IAM user, group, attaches permissions, adds to Service Catalog products.
9. Lambda returns provisioning outputs (AccountID, LoginURL) to Service Catalog.
*GovCloud flow is identical, just using templates under govcloud/govcloud-side-setup and commercial-side-setup.*
Architectural Patterns & Principles
• Serverless Orchestration: Lambda for orchestration, CloudFormation for infra provisioning.
• Infrastructure as Code: Templates version-controlled in repo, stored in S3.
• Least Privilege: Newly created IAM user has minimal permissions to use Service Catalog only.
• Multi-Tenant Partitioning: Accounts and OUs ensure separation.
• Extensibility: Separate pipelines for Commercial vs GovCloud.