User GuideΒΆ

Complete command reference for the SG Provisioner Tool.

Table of ContentsΒΆ


Quick StartΒΆ

Pre-Deployment ChecklistΒΆ

  • Docker 20.10+ installed and running (docker --version)

  • AWS credentials configured (aws sts get-caller-identity works)

  • AWS Marketplace subscription active for SG Provisioner

  • IAM permissions verified (see IAM_PERMISSIONS.md)

  • Configuration file created and validated

  • VPC deployed and VPC ID available (via SSM Parameter Store or direct ID)

  • Scenario selected for your architecture (use list-scenarios to view options)

  • Reviewed generated CloudFormation template

  • Tested in dev/staging environment first

1. Create Directories and Copy DocumentationΒΆ

cd ~
mkdir -p mlops-infra-suite/sg/{configs,policies,reports,templates,schemas}
cd mlops-infra-suite
mkdir -p sg/docs

# Create a temporary container
container_id=$(docker create sg-provisioner:latest)

# Copy docs from container to host
docker cp $container_id:/app/docs/. sg/docs/

# Remove the temporary container
docker rm $container_id

ls sg/docs/

The following directory tree is created and the documentation files are copied.

└── mlops-infra-suite
    └── sg
        β”œβ”€β”€ configs
        β”œβ”€β”€ docs
        β”‚   β”œβ”€β”€ _sources/
        β”‚   β”œβ”€β”€ _static/
        β”‚   β”œβ”€β”€ CONFIGURATION.html
        β”‚   β”œβ”€β”€ FEEDBACK.html
        β”‚   β”œβ”€β”€ IAM_PERMISSIONS.html
        β”‚   β”œβ”€β”€ README.html
        β”‚   β”œβ”€β”€ RELEASE_NOTES.html
        β”‚   β”œβ”€β”€ ROADMAP.html
        β”‚   β”œβ”€β”€ SCENARIOS.html
        β”‚   β”œβ”€β”€ SECURITY.html
        β”‚   β”œβ”€β”€ SECURITY_GUIDELINES.html
        β”‚   β”œβ”€β”€ SUPPORT.html
        β”‚   β”œβ”€β”€ TROUBLESHOOTING.html
        β”‚   β”œβ”€β”€ USER_GUIDE.html
        β”‚   β”œβ”€β”€ api_reference.html
        β”‚   β”œβ”€β”€ genindex.html
        β”‚   β”œβ”€β”€ index.html
        β”‚   β”œβ”€β”€ objects.inv
        β”‚   β”œβ”€β”€ py-modindex.html
        β”‚   β”œβ”€β”€ search.html
        β”‚   └── searchindex.js
        β”œβ”€β”€ policies
        β”œβ”€β”€ reports
        └── templates

Open sg/docs/index.html in your browser to view the documentation.

2. Copy Schemas and ScenariosΒΆ

# Create a temporary container
container_id=$(docker create sg-provisioner:latest)

# Copy schemas from container to host
docker cp $container_id:/app/schemas/. sg/schemas/

# Remove the temporary container
docker rm $container_id

ls sg/schemas/
ls sg/schemas/scenarios/

The schemas directory contains the validation schema and all available scenario templates:

└── mlops-infra-suite
    └── sg
        └── schemas
            β”œβ”€β”€ validation-schema.yaml
            └── scenarios
                β”œβ”€β”€ 2-tier-rds-postgresql.yaml
                β”œβ”€β”€ 2-tier-web.yaml
                β”œβ”€β”€ 3-tier-documentdb.yaml
                β”œβ”€β”€ 3-tier-oracle.yaml
                β”œβ”€β”€ 3-tier-rds-mysql.yaml
                β”œβ”€β”€ 3-tier-rds-postgresql.yaml
                β”œβ”€β”€ 3-tier-redshift.yaml
                β”œβ”€β”€ 3-tier-sqlserver.yaml
                └── 3-tier-web.yaml

Review the scenario YAML files to understand the security group rules that will be created for each architecture pattern.

3A. Prepare Configuration FileΒΆ

The configuration file contains your environment-specific settings and any overrides to the base scenario. The base scenario (e.g., 3-tier-web.yaml) lives in /app/schemas/scenarios/ inside the container β€” you copied these to sg/schemas/scenarios/ in Step 2. Your config file selects which scenario to use and applies customizations (port changes, additional rules) on top of it.

Create a YAML configuration file in mlops-infra-suite/sg/configs/ directory on host.

└── mlops-infra-suite
Β Β   └── sg
Β Β  Β Β  └── configs
Β Β  Β Β  Β Β  └── globalbank-prod-c001-us-west-2-sg.yaml

Here is an example YAML configuration file. Replace data elements with your data.

client:
  company_name: Global Bank
  company_prefix: globalbank
  account_id: "123456789012"
  tenant_id: "c001"

environment:
  env: prod
  region: us-west-2

security_groups:
  scenario: 3-tier-web
  vpc_source: parameter-store
  vpc_parameter_store_path: /vpc/globalbank-prod-c001-us-west-2-vpc/VPCId
  sg_name_override: ""
  workload: ""

  overrides:
    app:
      port_overrides:
        - protocol: tcp
          old_port: 8080
          new_port: 8443
      additional_ingress:
        - protocol: tcp
          port: 9090
          source_tier: web
          description: Prometheus metrics from web tier
    db:
      additional_ingress:
        - protocol: tcp
          port: 5432
          source_tier: app
          description: Read replica connection from app tier

tags:
  cost_center: Fraud Operations
  project: Real-time Credit Card Fraud Detection System
  owner: fraud-ml-engineering-team

3B. Verify Structure of Configuration FileΒΆ

The configuration file has four sections: client, environment, security_groups, and tags.

client:
  company_name: string          # Full company name
  company_prefix: string        # Short identifier (lowercase, pattern: ^[a-z][a-z0-9-]*$)
  account_id: "string"          # 12-digit AWS account ID (quoted)
  tenant_id: "string"           # 4-character alphanumeric (pattern: ^[a-z0-9]{4}$)

environment:
  env: string                   # prod, dev, test, staging
  region: string                # AWS region (e.g., us-west-2)

security_groups:
  scenario: string              # Scenario template name (e.g., 3-tier-web)
  vpc_source: string            # parameter-store or direct
  vpc_parameter_store_path: string  # SSM path (when vpc_source: parameter-store)
  vpc_id: string                # VPC ID (when vpc_source: direct)
  sg_name_override: ""          # Override auto-generated name (optional)
  workload: ""                  # Workload discriminator (optional)
  overrides:                    # Per-tier customizations (optional)
    <tier_name>:
      port_overrides: []
      additional_ingress: []
      additional_egress: []

tags:
  cost_center: string
  project: string
  owner: string

SG Naming Convention:

Format

Pattern

Example

Without workload

{prefix}-{env}-{tenant}-{region}-sg

globalbank-prod-c001-us-west-2-sg

With workload

{prefix}-{env}-{tenant}-{region}-{workload}-sg

globalbank-prod-c001-us-west-2-fraud-sg

For complete configuration reference including overrides, validation rules, and examples, see CONFIGURATION.md.

4A. Validate Configuration TemplateΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act validate-config

4B. List ScenariosΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act list-scenarios

4C. Show ScenarioΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act show-scenario

4D. Create Policy JSON FileΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/policies:/app/policies \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-policy

4E. Create Provisioning TemplateΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-prov-template

4F. Validate Provisioning TemplateΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act validate-prov-template

4G. Create Pre-deployment ReportsΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-review-report

4H. Test DeployΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act test-deploy

4I. Create Security Groups (Deployment)ΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-security-groups \
--force

4J. Show ChangesΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act show-changes

4K. Check DriftΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act check-drift

4L. Delete Security GroupsΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act delete-security-groups \
--force

5. Expected Output FilesΒΆ

sg/
β”œβ”€β”€ configs/
β”‚   └── globalbank-prod-c001-us-west-2-sg.yaml
β”œβ”€β”€ policies/
β”‚   └── globalbank-prod-c001-us-west-2-sg-iam-policy.json
β”œβ”€β”€ reports/
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-validate-config-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-list-scenarios-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-show-scenario-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-create-policy-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-create-prov-template-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-validate-prov-template-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-create-review-report-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-review-YYYYMMDD_HHMMSS.html
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-test-deploy-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-create-security-groups-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-deployment-YYYYMMDD_HHMMSS.html
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-show-changes-YYYYMMDD_HHMMSS_mmm.log
β”‚   β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-check-drift-YYYYMMDD_HHMMSS_mmm.log
β”‚   └── globalbank-prod-c001-us-west-2-sg-delete-security-groups-YYYYMMDD_HHMMSS_mmm.log
└── templates/
    β”œβ”€β”€ globalbank-prod-c001-us-west-2-sg-template.yaml
    └── globalbank-prod-c001-us-west-2-sg-review.yaml

File Naming Conventions:

  • Logs: <sg-name>-<action>-YYYYMMDD_HHMMSS_mmm.log

  • Pre-Deployment Report: <sg-name>-review-YYYYMMDD_HHMMSS.html

  • Post-Deployment Report: <sg-name>-deployment-YYYYMMDD_HHMMSS.html

  • Templates: <sg-name>-template.yaml

  • Policies: <sg-name>-iam-policy.json

File Types:

  • .log files contain detailed execution logs for troubleshooting

  • .html files are professional reports for visualization and documentation

  • .yaml files are CloudFormation templates

  • .json files are IAM policies for permission management

Security ScanningΒΆ

Optional: Scan Docker Image for VulnerabilitiesΒΆ

You can scan the SG Provisioner Docker image for security vulnerabilities using Trivy or any container scanning tool your organization uses.

Install Trivy:

# macOS
brew install trivy

# Linux
sudo apt-get install trivy

Run scan:

trivy image sg-provisioner:latest

Filter by severity:

trivy image --severity HIGH,CRITICAL sg-provisioner:latest

Note: OS-level vulnerabilities in the base image (Debian) are common and typically have no fixed version available yet. Python package vulnerabilities are more actionable β€” report any findings to support.


Commands ReferenceΒΆ

validate-configΒΆ

Check YAML configuration for schema compliance and syntax errors.

Purpose: Verify YAML syntax and schema compliance before deployment.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act validate-config

Output:

  • reports/<sg-name>-validate-config-YYYYMMDD_HHMMSS_mmm.log

What It Checks:

  • YAML syntax validity

  • Required fields present

  • Field value constraints (patterns, enums)


list-scenariosΒΆ

Lists all available scenario templates.

Purpose: Discover which architecture patterns are available.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act list-scenarios

Output:

  • Console listing of all scenario YAML files with descriptions.

  • reports/<sg-name>-list-scenarios-YYYYMMDD_HHMMSS_mmm.log


show-scenarioΒΆ

Displays the details of the scenario configured in your YAML file.

Purpose: Review the security group tiers, ports, and rules before deployment.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act show-scenario

Output:

  • Console display of tiers, ingress/egress rules, and ports for the selected scenario.

  • reports/<sg-name>-show-scenario-YYYYMMDD_HHMMSS_mmm.log


create-policyΒΆ

Generates an IAM policy JSON file scoped to your configuration.

Purpose: Produce a least-privilege IAM policy for attaching to your user/role.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/policies:/app/policies \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-policy

Output:

  • Report in console

  • reports/<sg-name>-create-policy-YYYYMMDD_HHMMSS_mmm.log

  • policies/<sg-name>-iam-policy.json


create-prov-templateΒΆ

Generates a CloudFormation template for the security groups.

Purpose: Create infrastructure-as-code for review before deployment.

AWS Credentials: Required.

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-prov-template

How It Works:

  1. Validates scenarios directory exists

  2. Validates VPC exists

  3. Loads the selected scenario

  4. Applies overrides from configuration (if any)

  5. Validates scenario rules (errors block generation unless --force is used)

  6. Generates and saves CloudFormation template

Output:

  • Report in console

  • reports/<sg-name>-create-prov-template-YYYYMMDD_HHMMSS_mmm.log

  • templates/<sg-name>-template.yaml β€” CloudFormation template


validate-prov-templateΒΆ

Validates the generated CloudFormation template locally.

Purpose: Catch template errors (syntax, references) before deployment.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act validate-prov-template

What It Checks:

  • YAML syntax valid

  • Required CloudFormation keys present (AWSTemplateFormatVersion, Resources)

  • All !Ref and !GetAtt targets resolve within the template

  • Resource types are valid for SG templates (AWS::EC2::SecurityGroup, AWS::EC2::SecurityGroupIngress, AWS::EC2::SecurityGroupEgress, AWS::SSM::Parameter)

Output:

  • reports/<sg-name>-validate-prov-template-YYYYMMDD_HHMMSS_mmm.log


create-review-reportΒΆ

Generates a pre-deployment review report.

Purpose: Produce an HTML report summarizing what will be deployed for stakeholder review.

AWS Credentials: Required (license validation).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-review-report

Output:

  • templates/<sg-name>-review.yaml β€” Human-readable review summary

  • reports/<sg-name>-review-YYYYMMDD_HHMMSS.html β€” Visual report

  • reports/<sg-name>-create-review-report-YYYYMMDD_HHMMSS_mmm.log


test-deployΒΆ

Deploys security groups with a random test suffix for safe testing.

Purpose: Validate that the template deploys successfully without affecting production.

AWS Credentials: Required.

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act test-deploy

How It Works:

  1. Generates a random 6-character suffix

  2. Builds test stack name using the suffix

  3. Loads scenario and applies overrides (if any)

  4. Generates CloudFormation template in-memory (not saved to disk)

  5. Deploys via CloudFormation and waits for completion

  6. Displays stack outputs

  7. Reminds user to delete the test stack

Output:

  • reports/<sg-name>-test-deploy-YYYYMMDD_HHMMSS_mmm.log

Cleanup: Delete the test stack when done:

aws cloudformation delete-stack --stack-name <test-stack-name> --region us-west-2

create-security-groupsΒΆ

Deploys security groups to AWS via CloudFormation.

Purpose: Production deployment of security groups.

AWS Credentials: Required.

Requires: --force flag.

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-security-groups \
  --force

What It Does:

  1. Reads the CloudFormation template from disk

  2. Provisions security groups through CloudFormation

  3. Stores stack outputs in SSM Parameter Store (/sg/<sg-name>/<tier>/SecurityGroupId)

    • e.g., /sg/globalbank-prod-c001-us-west-2-sg/web/SecurityGroupId

  4. Generates deployment report

Output:

  • reports/<sg-name>-deployment-YYYYMMDD_HHMMSS.html

  • reports/<sg-name>-create-security-groups-YYYYMMDD_HHMMSS_mmm.log


show-changesΒΆ

Previews pending changes without applying them.

Purpose: Review what would change in the deployed stack.

AWS Credentials: Required (deployed stack must exist).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act show-changes

How It Works:

  1. Checks the stack exists

  2. Reads the CloudFormation template from disk

  3. Creates a temporary ChangeSet

  4. Waits for ChangeSet creation

  5. Displays pending resource changes (Add, Modify, Remove) β€” or reports β€œNo changes detected”

  6. Deletes the ChangeSet (no changes applied)

Output:

  • reports/<sg-name>-show-changes-YYYYMMDD_HHMMSS_mmm.log


check-driftΒΆ

Detects infrastructure drift between the deployed stack and its template.

Purpose: Identify resources modified outside of CloudFormation.

AWS Credentials: Required (deployed stack must exist).

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act check-drift

What It Detects:

  • Security group rules added/removed manually

  • Tags modified outside CloudFormation

  • Security group descriptions changed

How It Works:

  1. Checks the stack exists

  2. Initiates CloudFormation drift detection

  3. Polls until detection is complete

  4. Reports per-resource drift details (property path, expected vs actual value)

Output:

  • reports/<sg-name>-check-drift-YYYYMMDD_HHMMSS_mmm.log


delete-security-groupsΒΆ

Deletes the CloudFormation stack and all security groups.

Purpose: Complete cleanup of deployed security groups.

AWS Credentials: Required.

Requires: --force flag.

Command:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act delete-security-groups \
  --force

What It Does:

  1. Deletes CloudFormation stack and waits for completion

  2. Removes SSM parameters under /sg/<sg-name>/

Output:

  • reports/<sg-name>-delete-security-groups-YYYYMMDD_HHMMSS_mmm.log


Command SummaryΒΆ

Action

AWS Creds

–force

Purpose

validate-config

βœ…

❌

Validate YAML

list-scenarios

βœ…

❌

List available scenarios

show-scenario

βœ…

❌

Display scenario details

create-policy

βœ…

❌

Generate IAM policy

create-prov-template

βœ…

❌

Generate CFN template

validate-prov-template

βœ…

❌

Validate CFN template locally

create-review-report

βœ…

❌

Generate review report

test-deploy

βœ…

❌

Safe test deployment

create-security-groups

βœ…

βœ…

Deploy security groups

show-changes

βœ…

❌

Preview pending changes

check-drift

βœ…

❌

Detect drift

delete-security-groups

βœ…

βœ…

Delete all SGs and stack


Common WorkflowsΒΆ

Complete DeploymentΒΆ

Full end-to-end workflow from validation to production deployment.

# 1. Validate configuration
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act validate-config

# 2. Review scenario
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act show-scenario

# 3. Generate IAM policy
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/policies:/app/policies \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act create-policy

# 4. Generate and review template
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act create-prov-template

# 5. Validate template
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act validate-prov-template

# 6. Generate review report
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act create-review-report

# 7. Test deploy
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act test-deploy

# 8. Preview changes before production deploy
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act show-changes

# 9. Deploy to production
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act create-security-groups --force

# 10. Verify no drift after deployment
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act check-drift

Quick TestΒΆ

Validate and generate artifacts without deploying to AWS.

# Validate + generate template + review report
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act validate-config

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act create-prov-template

# Review generated template
cat sg/templates/globalbank-prod-c001-us-west-2-sg-template.yaml

CleanupΒΆ

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml -act delete-security-groups --force

Multi-Workload DeploymentΒΆ

Deploy multiple SG sets in the same VPC using the workload discriminator.

# Deploy fraud workload SGs
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-fraud-sg.yaml -act create-security-groups --force

# Deploy payments workload SGs
docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-payments-sg.yaml -act create-security-groups --force

Each workload gets its own CloudFormation stack and SSM parameters with no naming collisions.


Volume MountsΒΆ

Mount

Container Path

Purpose

Required For

$(pwd)/sg/configs

/app/configs

Input configuration files

All actions

$(pwd)/sg/policies

/app/policies

Generated IAM policies

create-policy

$(pwd)/sg/templates

/app/templates

CloudFormation templates

create-prov-template, validate-prov-template, create-review-report, create-security-groups, show-changes

$(pwd)/sg/reports

/app/reports

Execution logs and HTML reports

All actions (recommended)

~/.aws

/home/sguser/.aws

AWS credentials

All actions requiring AWS access

Mount flags:

  • :ro β€” read-only (use for configs and credentials)

  • No flag β€” read-write (use for policies, templates, reports where tool writes output)

Example with all mounts:

docker run --rm \
  -v ~/.aws:/home/sguser/.aws:ro \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/policies:/app/policies \
  -v $(pwd)/sg/templates:/app/templates \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-security-groups --force

AWS CredentialsΒΆ

Option 2: Environment VariablesΒΆ

Pass credentials as environment variables.

docker run --rm \
  -e AWS_ACCESS_KEY_ID=AKIA... \
  -e AWS_SECRET_ACCESS_KEY=wJal... \
  -e AWS_DEFAULT_REGION=us-west-2 \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-security-groups --force

Option 3: IAM Role (EC2/ECS)ΒΆ

When running on EC2 or ECS with an IAM role attached, no manual credential configuration is needed. The AWS SDK inside the container automatically uses the instance/task role.

docker run --rm \
  -v $(pwd)/sg/configs:/app/configs:ro \
  -v $(pwd)/sg/reports:/app/reports \
  sg-provisioner:latest \
  -con globalbank-prod-c001-us-west-2-sg.yaml \
  -act create-security-groups --force

Best PracticesΒΆ

  1. Always validate first β€” Run validate-config before any AWS operations.

  2. Review templates β€” Inspect the generated CloudFormation template before deploying.

  3. Generate review report β€” Run create-review-report and share with stakeholders before deploying to production.

  4. Test before production β€” Use test-deploy or deploy to a dev environment first.

  5. Use Parameter Store for VPC ID β€” Decouples SG provisioning from VPC deployment.

  6. Use workload discriminator β€” Avoid naming collisions when deploying multiple SG sets.

  7. Keep overrides minimal β€” For fundamentally different architectures, create a new scenario.

  8. Use IAM roles over access keys in production.

  9. Monitor drift β€” Run check-drift periodically to detect manual changes.

  10. Version control configs β€” Store configuration files in Git for audit trail.

  11. Mount reports β€” Always mount the reports directory to capture logs for troubleshooting.


FAQΒΆ

Q: Can I modify the generated CloudFormation template? A: Yes, but changes are overwritten on next create-prov-template. Use configuration overrides instead.

Q: What happens if deployment fails? A: CloudFormation automatically rolls back. Check stack events and the log file in reports/ for details.

Q: Can I deploy multiple SG sets to the same VPC? A: Yes β€” use the workload field to create separate named SG sets (e.g., fraud, payments).

Q: How do I upgrade to a new version? A: Pull the latest Docker image. Existing deployed security groups are not affected unless you redeploy.

Q: What if the VPC doesn’t exist yet? A: Deploy the VPC first using the VPC Provisioner, or use vpc_source: direct with an existing VPC ID.

Q: How do I delete everything? A: Use delete-security-groups --force to remove the CloudFormation stack, all security groups, and SSM parameters.

Q: Can I deploy to multiple regions? A: Yes, create separate configuration files per region and run the tool for each.

Q: What’s the difference between test-deploy and create-security-groups? A: test-deploy appends a random suffix to avoid collisions with production. create-security-groups deploys with the real names.


Additional ResourcesΒΆ

  • CONFIGURATION.md β€” Complete configuration reference

  • SCENARIOS.md β€” Scenario details and customization

  • IAM_PERMISSIONS.md β€” Required AWS permissions

  • TROUBLESHOOTING.md β€” Common issues and solutions

  • SECURITY_GUIDELINES.md β€” Security best practices


Copyright Β© 2025 Axon Tech Labs. All rights reserved.

See LICENSE.txt for terms and conditions.