Skip to main content

Compliance Validation Architecture

Overview​

CloudForge CI checks infrastructure against compliance frameworks (SOC2, HIPAA, PCI-DSS, GDPR) in four layers. Each layer runs at a different stage of the deployment lifecycle and has its own enabling conditions.

LayerToolWhen it runsEnabled by
1cdk-nagDuring cdk synthsecurityProfile: production and at least one framework selected
2CloudForge FrameworkRulesDuring cdk synth (CDK node validations)auditManagerEnabled: true
3cfn-guardAfter synthesis, against the templateInteractive Deployer in enforce mode with frameworks selected; TruthTableValidationTest
4AWS ConfigAfter deploymentawsConfigEnabled: true

Multi-Layer Validation Flow​

sequenceDiagram
participant Dev as Developer/CI
participant CDK as CDK Synthesis
participant Nag as Layer 1: cdk-nag
participant Framework as Layer 2: FrameworkRules
participant Guard as Layer 3: cfn-guard
participant AWS as AWS Resources
participant Config as Layer 4: AWS Config

Dev->>CDK: cdk synth
CDK->>Nag: Apply NagPack aspects
CDK->>Framework: Run node validations
Framework-->>CDK: Violations (blocking in enforce mode)
CDK-->>Dev: Template and NagReport files
Dev->>Guard: cfn-guard validate (Interactive Deployer)
Guard-->>Dev: Pass or fail
Dev->>AWS: cdk deploy
AWS->>Config: Configuration changes recorded
Config->>Config: Evaluate rules
Config->>AWS: Automatic remediation (SSM Automation)

Layer Details​

Layer 1: cdk-nag​

Purpose: Construct-level checks from the cdk-nag rule packs.

Location: SecurityRules.applyCdkNagValidation in cloudforge-api/src/main/java/com/cloudforgeci/api/core/rules/.

Packs Used:

FrameworkPack
HIPAAHIPAASecurityChecks
PCI-DSSPCIDSS321Checks
SOC2AwsSolutionsChecks
Other valuesAwsSolutionsChecks

Each pack writes JSON and CSV NagReport files. app.synth() does not fail on cdk-nag findings by itself. When synthesis runs through CloudForgeSynthesizer in enforce mode, it reads the reports through NagReportReader and fails when error-level findings are present; other entry points, such as the sample Interactive Deployer, leave the reports for review.

Example Violations:

  • Missing encryption on EBS volumes
  • Overly permissive IAM policies
  • Public S3 buckets

Layer 2: FrameworkRules​

Purpose: CloudForge validators for framework-specific requirements that depend on deployment configuration, such as security profile, network mode, and authentication mode.

Location: cloudforge-api/src/main/java/com/cloudforgeci/api/core/rules/

Validators implement FrameworkRules<SystemContext>, are annotated with @ComplianceFramework, and are registered in META-INF/services/com.cloudforge.core.interfaces.FrameworkRules. FrameworkLoader discovers them with ServiceLoader and installs them in priority order: alwaysLoad validators always, other validators when their ID is in complianceFrameworks.

Registered validators:

ClassIDPriorityLoads
KeyManagementRulesKeyManagement-10always
DatabaseSecurityRulesDatabaseSecurity-5always
AdvancedMonitoringRulesAdvancedMonitoring-5always
ThreatProtectionRules, IncidentResponseRules, ComputeSecurityRules, LambdaSecurityRules, CdnApiSecurityRules, ElbSecurityRules, MessagingSecurityRules, IamSecurityRulesvarious0always
HipaaRulesHIPAA10hipaa selected
HipaaOrganizationalRulesHIPAA-Organizational15ID selected (not currently selectable)
PciDssRulesPCI-DSS20pci-dss selected
GdprRulesGDPR30gdpr selected
GdprOrganizationalRulesGDPR-Organizational35ID selected (not currently selectable)
Soc2RulesSOC240soc2 selected
Iso27001RulesISO-2700150ID selected (not currently selectable)

ConfigurationValidationRules, FedRampRules, and FedRampHighRules exist in the same package but are not registered, so they are not discovered. FedRAMP support is in development; see FedRAMP Controls Mapping.

Example Validation:

@Override
public void install(SystemContext ctx) {
if (ctx.security != SecurityProfile.PRODUCTION) {
return;
}
ctx.getNode().addValidation(() -> {
List<ComplianceRule> rules = new ArrayList<>();
rules.addAll(validateEncryption(ctx));
rules.addAll(validateAuditLogging(ctx));
// Failed rules become CDK validation errors in enforce mode
// and warnings in advisory mode.
...
});
}

Adding a framework: implement FrameworkRules<SystemContext>, annotate the class with @ComplianceFramework, and list it in a META-INF/services/com.cloudforge.core.interfaces.FrameworkRules file on the classpath. The sample project registers CustomSecurityPolicyRules and OpenSourceSecurityPolicyRules this way in cfc-testing/src/main/resources/META-INF/services/.

Layer 3: cfn-guard​

Purpose: Template-level policy checks with AWS CloudFormation Guard.

Location: cloudforge-api/src/main/resources/cfn-guard/frameworks/

Rule Files:

  • Cross-framework: iam-security.guard, compute-security.guard, lambda-security.guard, cdn-api-security.guard, elb-security.guard, database-security.guard, messaging-security.guard, key-management.guard, advanced-monitoring.guard, threat-protection.guard, incident-response.guard, iso-27001-controls.guard
  • Framework-specific: soc2-trust-services.guard, pci-dss-v4.0.1.guard, hipaa-security-rule.guard, gdpr-data-protection.guard

The Interactive Deployer runs the cross-framework files plus the files for the selected frameworks against cdk.out/<stackName>.template.json when complianceMode is enforce, and stops before deploying if any fail. It skips this layer when the cfn-guard binary is not installed. TruthTableValidationTest runs the same rules in the test suite.

Example Rule (iam-security.guard):

rule iam_security_policy_full_admin when
resourceType in ['AWS::IAM::Policy'] {
Properties.PolicyDocument.Statement[*] {
when Effect == 'Allow' {
Action != '*' <<Policies must not grant full administrator access>>
}
}
}

Layer 4: AWS Config​

Purpose: Evaluation of deployed resources and automatic remediation.

Location: ComplianceFactory in cloudforge-api/src/main/java/com/cloudforgeci/api/observability/

Config Rules:

  • Base rules: encryption (EBS, S3), S3 public access and versioning, IAM password policy, CloudTrail
  • Framework-specific rules: deployed under CloudFormation conditions for each selected framework; database rules also require provisionDatabase
  • Collected rules: registered by other factories only for resources that are created
  • Conformance packs: deployed for selected frameworks

Remediation Examples:

  • IAM password policy updates
  • S3 versioning enforcement (enableS3VersioningRemediation)
  • CloudTrail bucket access fixes (enableCloudTrailBucketAccessRemediation)
  • RDS deletion protection (enableRdsDeletionProtectionRemediation)

See Automated Compliance and Retained Resources for the full list.

Unit and Integration Tests​

JUnit tests validate configuration logic and rule behavior during development and CI. They are separate from the four runtime layers.

What they cover:

  • Field validation (required fields, enum values)
  • Configuration logic (security profile requirements)
  • Default value behavior
  • Framework-specific rule outcomes, including the CSV-driven matrix in TruthTableValidationTest

Location: cloudforge-api/src/test/java/

See CSV Parameterized Testing and Compliance Truth Tables.

Compliance Mode​

ModeBehaviorDefault for
ENFORCEFramework validator failures block synthesis; cdk-nag errors block when synthesizing through CloudForgeSynthesizer; the Interactive Deployer also runs cfn-guardproduction
ADVISORYViolations are logged as warnings; deployment continuesdev, staging
DISABLEDComplianceMatrix does not force framework-required controls on. The PCI-DSS, HIPAA, SOC2, and GDPR validators currently treat it like enforce; disable them with auditManagerEnabled: falsenone

Framework Coverage​

FrameworkValidatorscdk-nag Packcfn-guard FileTest Matrix
SOC2Soc2RulesAwsSolutionsCheckssoc2-trust-services.guardcompliance-matrices/soc2_*
HIPAAHipaaRulesHIPAASecurityCheckshipaa-security-rule.guardcompliance-matrices/hipaa_*
PCI-DSSPciDssRulesPCIDSS321Checkspci-dss-v4.0.1.guardcompliance-matrices/pci-dss_*
GDPRGdprRulesAwsSolutionsChecksgdpr-data-protection.guardcompliance-matrices/gdpr_*

Passing these checks shows that the configured controls match the encoded rules. It is not a certification or audit opinion.