Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature disable tests #796

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions src/lambda_codebase/initial_commit/adfconfig.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ config:
allow-empty-target: disabled
# ^ Needs to be set to "enabled" to activate. Defaults to "disabled" when
# not set.

# Tells whether or not run tests during the bootstrap pipeline,
# Needs to be set to "enabled" to activate. Defaults to "disabled" when not set
run-tests: disabled

# Optional config for multi-organization deployments of ADF:
# org:
# # Optional: Use this variable to define the AWS Organization in case of
Expand Down
72 changes: 41 additions & 31 deletions src/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Resources:
- !GetAtt JumpRoleApplication.Outputs.ManagerFunctionArn

AccountFileProcessingFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: process_account_files.lambda_handler
Description: >-
Expand All @@ -399,7 +399,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
ACCOUNT_MANAGEMENT_STATEMACHINE_ARN: !Ref AccountManagementStateMachine
ADF_PRIVILEGED_CROSS_ACCOUNT_ROLE_NAME: !Ref CrossAccountAccessRoleName
Expand Down Expand Up @@ -450,7 +450,7 @@ Resources:
- !Ref AccountProcessingLambdaBasePolicy

AccountAliasConfigFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: configure_account_alias.lambda_handler
Description: ADF - Account Management - Account Alias Configuration
Expand All @@ -463,7 +463,7 @@ Resources:
AWS_PARTITION: !Ref AWS::Partition
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
ADF_PRIVILEGED_CROSS_ACCOUNT_ROLE_NAME: !Ref CrossAccountAccessRoleName
FunctionName: adf-account-management-config-alias
Expand Down Expand Up @@ -499,7 +499,7 @@ Resources:
- !Sub "arn:${AWS::Partition}:organizations::${AWS::AccountId}:account/${Organization.OrganizationId}/*"

AccountTagConfigFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: configure_account_tags.lambda_handler
Description: ADF - Account Management - Account Tag Configuration
Expand All @@ -511,7 +511,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
FunctionName: adf-account-management-config-tags
Role: !GetAtt AccountTagConfigFunctionRole.Arn
Expand Down Expand Up @@ -550,7 +550,7 @@ Resources:
- !Sub "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/adf/target_regions"

AccountRegionConfigFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: configure_account_regions.lambda_handler
Description: ADF - Account Management - Account Region Configuration
Expand All @@ -562,15 +562,15 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
FunctionName: adf-account-management-config-region
Role: !GetAtt AccountRegionConfigFunctionRole.Arn
Metadata:
BuildMethod: python3.12

AccountOUConfigFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: configure_account_ou.lambda_handler
Description: ADF - Account Management - Account OU Configuration
Expand All @@ -582,7 +582,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
FunctionName: adf-account-management-config-ou
Role: !GetAtt AccountOUConfigFunctionRole.Arn
Expand Down Expand Up @@ -620,7 +620,7 @@ Resources:
Resource: "*"

GetAccountRegionsFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: get_account_regions.lambda_handler
Description: ADF - Account Management - Get Default Regions
Expand All @@ -633,7 +633,7 @@ Resources:
AWS_PARTITION: !Ref AWS::Partition
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
ADF_PRIVILEGED_CROSS_ACCOUNT_ROLE_NAME: !Ref CrossAccountAccessRoleName
FunctionName: adf-account-management-get-regions
Expand All @@ -660,7 +660,7 @@ Resources:
- !Ref AccountProcessingLambdaBasePolicy

DeleteDefaultVPCFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: delete_default_vpc.lambda_handler
Description: ADF - Account Management - Delete the Default VPCs
Expand All @@ -673,7 +673,7 @@ Resources:
AWS_PARTITION: !Ref AWS::Partition
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
ADF_PRIVILEGED_CROSS_ACCOUNT_ROLE_NAME: !Ref CrossAccountAccessRoleName
FunctionName: adf-account-management-delete-default-vpc
Expand All @@ -700,7 +700,7 @@ Resources:
- !Ref AccountProcessingLambdaBasePolicy

CreateAccountFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: create_account.lambda_handler
Description: ADF - Account Management - Create Account
Expand All @@ -712,7 +712,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
ADF_PRIVILEGED_CROSS_ACCOUNT_ROLE_NAME: !Ref CrossAccountAccessRoleName
FunctionName: adf-account-management-create-account
Expand Down Expand Up @@ -747,7 +747,7 @@ Resources:
Resource: "*"

RegisterAccountForSupportFunction:
Type: 'AWS::Serverless::Function'
Type: "AWS::Serverless::Function"
Properties:
Handler: register_account_for_support.lambda_handler
Description: ADF - Account Management - Register support level
Expand All @@ -759,7 +759,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
ORGANIZATION_ID: !GetAtt Organization.OrganizationId
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
FunctionName: adf-account-management-register-support-level
Role: !GetAtt RegisterAccountForSupportFunctionRole.Arn
Expand Down Expand Up @@ -1101,7 +1101,6 @@ Resources:
}
}
### Account processing end

ADFSharedPythonLambdaLayerVersion:
Type: "AWS::Serverless::LayerVersion"
Properties:
Expand Down Expand Up @@ -1152,7 +1151,7 @@ Resources:
Location: account_bootstrapping_jump_role.yml
Parameters:
OrganizationId: !GetAtt Organization.OrganizationId
ADFVersion: !FindInMap ['Metadata', 'ADF', 'Version']
ADFVersion: !FindInMap ["Metadata", "ADF", "Version"]
LambdaLayer: !Ref ADFSharedPythonLambdaLayerVersion
CrossAccountAccessRoleName: !Ref CrossAccountAccessRoleName
DeploymentAccountId: !GetAtt DeploymentAccount.AccountId
Expand Down Expand Up @@ -1311,8 +1310,7 @@ Resources:
Resource: !GetAtt BootstrapTemplatesBucket.Arn
- Effect: "Allow"
Action: "s3:GetObject"
Resource:
!Sub "${BootstrapTemplatesBucket.Arn}/*"
Resource: !Sub "${BootstrapTemplatesBucket.Arn}/*"

CrossAccountDeployBootstrapFunction:
Type: "AWS::Serverless::Function"
Expand Down Expand Up @@ -1491,9 +1489,9 @@ Resources:
Statement:
- Effect: Allow
Action:
- 'support:CreateCase'
- 'support:DescribeSeverityLevels'
Resource: '*'
- "support:CreateCase"
- "support:DescribeSeverityLevels"
Resource: "*"

CodeBuildPolicy:
Type: "AWS::IAM::ManagedPolicy"
Expand Down Expand Up @@ -1663,17 +1661,29 @@ Resources:
python: 3.12
pre_build:
commands:
- pip install yq --root-user-action ignore --quiet
- ADF_PERFORM_TESTS=`cat adfconfig.yml | yq -r '.config."run-tests" // "disabled"'`
- >-
pip install
-r requirements-dev.txt
-r adf-build/requirements.txt
-r adf-build/requirements-dev.txt
-r adf-build/shared/requirements.txt
-r adf-build/shared/requirements-dev.txt
-r adf-build/shared/helpers/requirements.txt
-r adf-build/shared/helpers/requirements-dev.txt
--root-user-action ignore
--quiet
- tox
- |
if [ "$ADF_PERFORM_TESTS" = "enabled" ] ; then
echo "Performing tests"
pip install \
-r requirements-dev.txt \
-r adf-build/requirements-dev.txt \
-r adf-build/shared/requirements-dev.txt \
-r adf-build/shared/helpers/requirements-dev.txt \
--quiet \
--root-user-action ignore
tox
else
echo "Skipping tests"
fi
- >-
docker run --privileged --rm
public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v7.0.0
Expand Down Expand Up @@ -2282,7 +2292,7 @@ Resources:
Variables:
MANAGEMENT_ACCOUNT_ID: !Ref AWS::AccountId
DEPLOYMENT_REGION: !Ref DeploymentAccountMainRegion
ADF_VERSION: !FindInMap ['Metadata', 'ADF', 'Version']
ADF_VERSION: !FindInMap ["Metadata", "ADF", "Version"]
ADF_LOG_LEVEL: !Ref LogLevel
Policies:
- Version: "2012-10-17"
Expand Down