Skip to content

Commit

Permalink
conformence update
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Feb 20, 2025
1 parent e922858 commit 23bdb7c
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 14 deletions.
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountAuditManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
#############################################
# Part 1 - Import Custom Framework
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPart8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Type: AWS::Lambda::LayerVersion
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/AuditAccountPreRequisitesPartN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
#############################################
# Configure Lambda Permissions
Expand Down
13 changes: 2 additions & 11 deletions arch/templates/ConformancePack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ Parameters:
UpdateTriggerVersion:
Type: String
Default: "v1"
TemplateVersion:
Type: String
Default: !Sub "${AWS::StackName}-v3-${AWS::Timestamp}"
GCLambdaExecutionRoleName:
Type: String
GCLambdaExecutionRoleName2:
Expand Down Expand Up @@ -115,15 +112,9 @@ Parameters:
S3EmergencyAccountAlertsRuleNamesPath:
Type: String

Metadata:
ForceUpdate: 1740069923
Resources:
# Force Update
ForceUpdateFunction:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub "/force-update/${AWS::StackName}/${TemplateVersion}"
Type: String
Value: !Ref TemplateVersion

# GC01
GC01CheckAttestationLetterConfigRule:
Type: "AWS::Config::ConfigRule"
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/EvidenceCollectionComponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Conditions:
- !Ref AWS::AccountId
- !Ref AuditAccountID

Metadata:
ForceUpdate: 1740069923
Resources:
CloudGuardrailsCommonLayer:
Condition: IsAuditAccount
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/OrgRoleGenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Parameters:
Description:
The python runtime to use for the compliance dashboard

Metadata:
ForceUpdate: 1740069923
Resources:
LambdaCreateRole:
Type: "AWS::IAM::Role"
Expand Down
4 changes: 3 additions & 1 deletion arch/templates/config-aggregator.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
AWSTemplateFormatVersion: 2010-09-09
Description: Deploys the Government of Canada Guardrails Assessment Package Configuration Aggregator

Metadata:
ForceUpdate: 1740069923
Resources:
ConfigurationAggregator:
Type: 'AWS::Config::ConfigurationAggregator'
Expand Down Expand Up @@ -29,4 +31,4 @@ Resources:
- 'sts:AssumeRole'
Tags:
- Key: "Source"
Value: "ProServe Delivery Kit"
Value: "ProServe Delivery Kit"
2 changes: 1 addition & 1 deletion arch/templates/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AWSTemplateFormatVersion: 2010-09-09
Description: Deploys the Government of Canada Guardrails Assessment Package

Metadata:
ForceUpdateTimeStamp: !Sub "${AWS::Timestamp}"
ForceUpdate: 1740069923
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
Expand Down
2 changes: 2 additions & 0 deletions arch/templates/root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Parameters:
Type: String
Default: 2.0.0

Metadata:
ForceUpdate: 1740069923
Resources:
GuardRailsStack:
Type: AWS::CloudFormation::Stack
Expand Down
Binary file modified cloudshell.zip
Binary file not shown.
42 changes: 41 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,48 @@ $(info --- Checking dependencies [DONE] ---)

## Make all, build and deploy
all: configure mb build-code package-code setup-organizations deploy-stack backup-config

# Define variables
TIMESTAMP := $(shell date +%s)
TEMPLATE_DIR := arch/templates
YAML_FILES := $(shell find $(TEMPLATE_DIR) -type f -name "*.yaml")

# Add force update metadata only to CloudFormation templates
force-update-yaml:
@echo "Processing CloudFormation YAML templates in $(TEMPLATE_DIR)..."
@for file in $(YAML_FILES); do \
if grep -q "Resources:" $$file; then \
if grep -q "Metadata:" $$file; then \
# Metadata exists, append ForceUpdate inside Metadata block
sed -i '/Metadata:/a\ ForceUpdate: '$(TIMESTAMP)'' $$file; \
echo "Updated Metadata in $$file"; \
else \
# Metadata doesn't exist, insert it correctly
awk '/Resources:/ {print "Metadata:\n ForceUpdate: '$(TIMESTAMP)'"}1' $$file > $$file.tmp && mv $$file.tmp $$file; \
echo "Added Metadata to $$file"; \
fi \
else \
echo "Skipping $$file (Not a CloudFormation template)"; \
fi \
done
@echo "CloudFormation YAML templates updated successfully."

# Validate YAML syntax before packaging
validate-yaml:
@echo "Validating YAML syntax..."
@for file in $(YAML_FILES); do \
yq eval . $$file > /dev/null || { echo "Error in $$file"; exit 1; }; \
done
@echo "All CloudFormation YAML files in $(TEMPLATE_DIR) are valid."

# Main target to prepare YAMLs for forced update
force-conformence: force-update-yaml validate-yaml
@echo "YAML files updated and validated successfully. Ready for packaging."



## Build a cloudshell package, build code and package for cloudshell
build-cloudshell-package: build-code create-cloudshell-package
build-cloudshell-package: force-conformence build-code create-cloudshell-package
## Build and package code
build: build-code package-code
## Build and deploy code
Expand Down

0 comments on commit 23bdb7c

Please sign in to comment.