Skip to content

chore(ci): add support for x86-64 regions only #2122

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

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 59 additions & 27 deletions .github/workflows/reusable_deploy_v2_layer_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,63 @@ jobs:
strategy:
fail-fast: false
matrix:
region:
[
"af-south-1",
"eu-central-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ap-east-1",
"ap-south-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-south-1",
"eu-north-1",
"sa-east-1",
"ap-southeast-3",
"ap-northeast-3",
"me-south-1",
]
# To get a list of current regions, use:
# aws ec2 describe-regions --all-regions --query "Regions[].RegionName" --output text | tr "\t" "\n" | sort
include:
- region: "af-south-1"
has_arm64_support: "true"
- region: "ap-east-1"
has_arm64_support: "true"
- region: "ap-northeast-1"
has_arm64_support: "true"
- region: "ap-northeast-2"
has_arm64_support: "true"
- region: "ap-northeast-3"
has_arm64_support: "true"
- region: "ap-south-1"
has_arm64_support: "true"
- region: "ap-south-2"
has_arm64_support: "false"
- region: "ap-southeast-1"
has_arm64_support: "true"
- region: "ap-southeast-2"
has_arm64_support: "true"
- region: "ap-southeast-3"
has_arm64_support: "true"
- region: "ap-southeast-4"
has_arm64_support: "false"
- region: "ca-central-1"
has_arm64_support: "true"
- region: "eu-central-1"
has_arm64_support: "true"
- region: "eu-central-2"
has_arm64_support: "false"
- region: "eu-north-1"
has_arm64_support: "true"
- region: "eu-south-1"
has_arm64_support: "true"
- region: "eu-south-2"
has_arm64_support: "false"
- region: "eu-west-1"
has_arm64_support: "true"
- region: "eu-west-2"
has_arm64_support: "true"
- region: "eu-west-3"
has_arm64_support: "true"
- region: "me-central-1"
has_arm64_support: "false"
- region: "me-south-1"
has_arm64_support: "true"
- region: "sa-east-1"
has_arm64_support: "true"
- region: "us-east-1"
has_arm64_support: "true"
- region: "us-east-2"
has_arm64_support: "true"
- region: "us-west-1"
has_arm64_support: "true"
- region: "us-west-2"
has_arm64_support: "true"
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -99,7 +131,7 @@ jobs:
- name: unzip artefact
run: unzip cdk.out.zip
- name: CDK Deploy Layer
run: npx cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose --outputs-file cdk-outputs.json
run: npx cdk deploy --app cdk.out --context region=${{ matrix.region }} --parameters HasARM64Support=${{ matrix.has_arm64_support }} 'LayerV2Stack' --require-approval never --verbose --outputs-file cdk-outputs.json
- name: Store latest Layer ARN
if: ${{ inputs.stage == 'PROD' }}
run: |
Expand All @@ -116,7 +148,7 @@ jobs:
if-no-files-found: error
retention-days: 1
- name: CDK Deploy Canary
run: npx cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryV2Stack' --require-approval never --verbose
run: npx cdk deploy --app cdk.out --context region=${{ matrix.region }} --parameters DeployStage="${{ inputs.stage }}" --parameters HasARM64Support=${{ matrix.has_arm64_support }} 'CanaryV2Stack' --require-approval never --verbose

update_v2_layer_arn_docs:
needs: deploy-cdk-stack
Expand Down
2 changes: 1 addition & 1 deletion layer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
app,
"LayerV2Stack",
powertools_version=POWERTOOLS_VERSION,
ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN,
ssm_parameter_layer_arn=SSM_PARAM_LAYER_ARN,
ssm_parameter_layer_arm64_arn=SSM_PARAM_LAYER_ARM64_ARN,
)

Expand Down
49 changes: 46 additions & 3 deletions layer/layer/canary_stack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import uuid

from aws_cdk import CfnParameter, CustomResource, Duration, Stack
from aws_cdk.aws_iam import Effect, ManagedPolicy, PolicyStatement, Role, ServicePrincipal
import jsii
from aws_cdk import (
Aspects,
CfnCondition,
CfnParameter,
CfnResource,
CustomResource,
Duration,
Fn,
IAspect,
Stack,
)
from aws_cdk.aws_iam import (
Effect,
ManagedPolicy,
PolicyStatement,
Role,
ServicePrincipal,
)
from aws_cdk.aws_lambda import Architecture, Code, Function, LayerVersion, Runtime
from aws_cdk.aws_logs import RetentionDays
from aws_cdk.aws_ssm import StringParameter
Expand All @@ -13,6 +30,16 @@
)


@jsii.implements(IAspect)
class ApplyCondition:
def __init__(self, condition: CfnCondition):
self.condition = condition

def visit(self, node):
if isinstance(node, CfnResource):
node.cfn_options.condition = self.condition


class CanaryStack(Stack):
def __init__(
self,
Expand All @@ -29,6 +56,20 @@ def __init__(
self, "DeployStage", description="Deployment stage for canary"
).value_as_string

has_arm64_support = CfnParameter(
self,
"HasARM64Support",
description="Has ARM64 Support Condition",
type="String",
allowed_values=["true", "false"],
)

has_arm64_condition = CfnCondition(
self,
"HasARM64SupportCondition",
expression=Fn.condition_equals(has_arm64_support, "true"),
)

layer_arn = StringParameter.from_string_parameter_attributes(
self, "LayerVersionArnParam", parameter_name=ssm_paramter_layer_arn
).string_value
Expand All @@ -46,14 +87,16 @@ def __init__(
"LayerArm64VersionArnParam",
parameter_name=ssm_parameter_layer_arm64_arn,
).string_value
Canary(

arm64_canary = Canary(
self,
"Canary-arm64",
layer_arn=layer_arm64_arn,
powertools_version=powertools_version,
architecture=Architecture.ARM_64,
stage=deploy_stage,
)
Aspects.of(arm64_canary).add(ApplyCondition(has_arm64_condition))


class Canary(Construct):
Expand Down
Loading