Feature #47
openFeature #33: Canofy Control Centre Backend Development
Feature #46: Canofy Control Centre Onboarding Process
New Client Onboarding — Automated AWS + Frappe Provisioning
0%
Description
[CANOFY-101] Provision EC2 Instance¶
Type: Story
Epic: New Client Onboarding — Automated AWS + Frappe Provisioning
Stage key: aws_provision (pipeline stage 1 of 15)
Component: utils/aws_client.py, utils/onboarding_executor.py
User Story¶
As an operations engineer,
I want the client's EC2 instance provisioned automatically from the
approved Onboarding Request,
so that every new client server is created consistently (encrypted
storage, no SSH access, correct sizing) without manual AWS console work.
Description¶
Implement the first pipeline stage: create a single EC2 instance for the new
client using the parameters captured on Onboarding Request
(aws_region, instance_type, storage_gb, site_name as the Name tag).
Requirements:
- No
KeyNamepassed toRunInstances— SSH access must never be possible. - Root EBS volume: encrypted,
DeleteOnTermination=True, typegp3, sized
fromstorage_gb. - Security group(s) come from the
AWS Account.default_security_group_id
and must be HTTPS-only (no port 22 ingress) — the account is the source
of truth, not something entered per-request. - Subnet comes from
AWS Account.default_subnet_id. - Support an "AMI Image" deployment mode: if
Onboarding Request .deployment_mode == "AMI Image", resolve the latest AMI tagged
ami_tag_valueinstead of the default Ubuntu 22.04 base image. - On
InsufficientInstanceCapacity(or equivalent capacity error) for the
configured subnet's AZ, automatically retry in sibling subnets of the same
VPC (other AZs) before failing the stage — AWS's own error message for
this condition explicitly recommends trying a different AZ, so this
should not require human intervention for a routine capacity blip. - Resulting
instance_idis written toOnboarding Request.ec2_instance_id
and threaded through the pipeline context for later stages.
Configuration / Prerequisites¶
-
AWS Accountrecord withdefault_security_group_idand
default_subnet_idpopulated. Stage must refuse to run (clear error, not
a silent default) ifdefault_security_group_idis unset. -
AWS Account.use_oidc=1+ validoidc_role_arnif the account uses OIDC
federation — all AWS calls must be made through the account's assumed
role, never the bare default credential chain. -
Onboarding Requestfields populated:aws_account,aws_region,
instance_type,storage_gb,site_name.
Acceptance Criteria¶
-
Instance is created with no
KeyName. -
Root volume is encrypted and matches
storage_gb. - Security group has zero port-22 ingress rules.
-
Onboarding Request.ec2_instance_idis populated after this stage. -
A capacity error in one AZ results in an automatic retry in a
different AZ of the same VPC, not an immediate stage failure. -
If capacity is unavailable in every subnet of the VPC, the stage fails
with a clear error naming every subnet tried. -
Missing
default_security_group_idfails fast with an explicit
message, before any AWS API call is made.
Test Cases¶
| ID | Scenario | Steps | Expected Result |
|---|---|---|---|
| TC-1 | Happy path | Run stage with valid account/region/instance_type | Instance created, running state, correct tags (Name=site_name, ManagedBy=canofy-control-centre) |
| TC-2 | No SSH key | Inspect created instance |
KeyName is null/absent |
| TC-3 | Encrypted root volume | Describe instance's root EBS volume |
Encrypted=true, size matches storage_gb
|
| TC-4 | Capacity fallback | Force InsufficientInstanceCapacity on the primary subnet (or simulate via a full/unavailable instance type in one AZ) |
Instance is created in an alternate subnet/AZ of the same VPC; stage succeeds |
| TC-5 | Capacity exhausted everywhere | All subnets in the VPC report capacity errors | Stage fails with an error listing every subnet ID attempted |
| TC-6 | AMI Image mode | Set deployment_mode="AMI Image" with a valid ami_tag_value
|
Instance launched from the resolved golden AMI, not the default Ubuntu image |
| TC-7 | Missing security group config |
AWS Account.default_security_group_id empty |
Stage fails immediately with a clear configuration error, no RunInstances call attempted |
| TC-8 | Missing subnet |
AWS Account.default_subnet_id empty |
SubnetId omitted from the API call; AWS chooses any AZ with capacity in the default VPC |
Files
AS Updated by Akshath Shettigara about 1 month ago
- Status changed from New to In Progress
AS Updated by Akshath Shettigara about 1 month ago
- File 15-smoke-test.md 15-smoke-test.md added