Skip to content

Commit

Permalink
CMDCT-4243 - serverless v4 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
peoplespete committed Jan 17, 2025
1 parent ccaedd5 commit 0e09798
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LOGGING_BUCKET=log-bucket
S3_LOCAL_ENDPOINT=http://localhost:4569
SKIP_PREFLIGHT_CHECK=true
QMS_REPORT_TABLE_NAME=local-qms-reports
SERVERLESS_LICENSE_KEY=op://mdct_devs/hcbs_secrets/SERVERLESS_LICENSE_KEY

# Values used for short-circuiting ssm: lookups, most likely won't need locally
VPC_ID=local-nonsense
Expand All @@ -33,4 +34,4 @@ SEED_ADMIN_USER_PASSWORD=op://mdct_devs/hcbs_secrets/SEED_ADMIN_USER_PASSWORD #
SEED_STATE_USER_EMAIL=op://mdct_devs/hcbs_secrets/SEED_STATE_USER_EMAIL
SEED_STATE_USER_PASSWORD=op://mdct_devs/hcbs_secrets/SEED_STATE_USER_PASSWORD # pragma: allowlist secret
SEED_STATE=op://mdct_devs/hcbs_secrets/SEED_STATE
SEED_STATE_NAME=op://mdct_devs/hcbs_secrets/SEED_STATE_NAME
SEED_STATE_NAME=op://mdct_devs/hcbs_secrets/SEED_STATE_NAME
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ permissions:
actions: read
pages: write

env:
SERVERLESS_LICENSE_KEY: ${{ secrets.SERVERLESS_LICENSE_KEY }}

jobs:
unit-tests:
name: Unit Tests
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^2.4.1",
"serverless": "^3.39.0",
"serverless": "^4.4.18",
"serverless-bundle": "^6.0.0",
"serverless-dotenv-plugin": "^3.0.0",
"serverless-dynamodb": "^0.2.54",
Expand Down
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi
# check serverless is installed globally.
if ! which serverless > /dev/null ; then
echo "installing serverless globally"
yarn global add serverless@3.38.0
yarn global add serverless@4.4.18
fi

# have to ensure that yarn install is up to date.
Expand Down
6 changes: 3 additions & 3 deletions services/app-api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
service: app-api

frameworkVersion: "3"
frameworkVersion: "4"

package:
individually: true
Expand Down Expand Up @@ -57,8 +57,8 @@ provider:
restApi: true
iam:
role:
path: ${env:IAM_PATH, ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${env:IAM_PERMISSIONS_BOUNDARY, ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
path: /delegatedadmin/developer/
permissionsBoundary: !Sub arn:aws:iam::${AWS::AccountId}:policy/cms-cloud-admin/developer-boundary-policy
statements:
- Effect: "Allow"
Action:
Expand Down
6 changes: 3 additions & 3 deletions services/database/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
service: database

frameworkVersion: "3"
frameworkVersion: "4"

plugins:
- serverless-dynamodb
Expand Down Expand Up @@ -44,8 +44,8 @@ provider:
SERVICE: ${self:service}
iam:
role:
path: ${env:IAM_PATH, ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${env:IAM_PERMISSIONS_BOUNDARY, ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
path: /delegatedadmin/developer/
permissionsBoundary: !Sub arn:aws:iam::${AWS::AccountId}:policy/cms-cloud-admin/developer-boundary-policy
statements:
- Effect: "Allow"
Action:
Expand Down
12 changes: 3 additions & 9 deletions services/ui-auth/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Refer to the README.md file in within this service directory to configure all ssm parameters required for this service.
service: ui-auth

frameworkVersion: "3"
frameworkVersion: "4"

package:
individually: true
Expand All @@ -15,8 +15,8 @@ provider:
SERVICE: ${self:service}
iam:
role:
path: ${ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
path: /delegatedadmin/developer/
permissionsBoundary: !Sub arn:aws:iam::${AWS::AccountId}:policy/cms-cloud-admin/developer-boundary-policy
statements:
- Effect: "Allow"
Action:
Expand All @@ -28,14 +28,8 @@ plugins:
- serverless-plugin-scripts
- serverless-bundle
- serverless-iam-helper
- serverless-s3-bucket-helper
- "@enterprise-cmcs/serverless-waf-plugin"

s3BucketHelper:
loggingConfiguration:
path: ${env:IAM_PATH, ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${env:IAM_PERMISSIONS_BOUNDARY, ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}

custom:
project: "hcbs"
stage: ${opt:stage, self:provider.stage}
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
service: ui-src

frameworkVersion: "3"
frameworkVersion: "4"

plugins:
- serverless-plugin-scripts
Expand Down
44 changes: 11 additions & 33 deletions services/ui/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Refer to the README.md file in within this service directory to configure all ssm parameters required for this service.
service: ui

frameworkVersion: "3"
frameworkVersion: "4"

provider:
name: aws
Expand All @@ -12,21 +12,15 @@ provider:
SERVICE: ${self:service}
iam:
role:
path: ${env:IAM_PATH, ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${env:IAM_PERMISSIONS_BOUNDARY, ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
path: /delegatedadmin/developer/
permissionsBoundary: !Sub arn:aws:iam::${AWS::AccountId}:policy/cms-cloud-admin/developer-boundary-policy

plugins:
- serverless-plugin-scripts
- serverless-stack-termination-protection
- serverless-iam-helper
- serverless-s3-bucket-helper
- "@enterprise-cmcs/serverless-waf-plugin"

s3BucketHelper:
loggingConfiguration:
destinationBucketName: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsBucket, ssm:/configuration/default/s3/accessLogsBucket}
logFilePrefix: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsPrefix, ssm:/configuration/default/s3/accessLogsPrefix}

custom:
project: "hcbs"
stage: ${opt:stage, self:provider.stage}
Expand All @@ -36,8 +30,6 @@ custom:
- main
- val
- production
route53HostedZoneId: ${ssm:/configuration/${self:custom.stage}/route53/hostedZoneId, ssm:/configuration/default/route53/hostedZoneId, ""}
route53DomainName: ${ssm:/configuration/${self:custom.stage}/route53/domainName, ""}
cloudfrontCertificateArn: ${ssm:/configuration/${self:custom.stage}/cloudfront/certificateArn, ssm:/configuration/default/cloudfront/certificateArn, ""}
cloudfrontDomainName: ${ssm:/configuration/${self:custom.stage}/cloudfront/domainName, ""}
vpnIpSetArn: ${ssm:/configuration/${self:custom.stage}/vpnIpSetArn, ssm:/configuration/default/vpnIpSetArn, ""}
Expand Down Expand Up @@ -105,16 +97,6 @@ params:

resources:
Conditions:
CreateDnsRecord:
Fn::And:
- Fn::Not:
- Fn::Equals:
- ""
- ${self:custom.route53HostedZoneId}
- Fn::Not:
- Fn::Equals:
- ""
- ${self:custom.route53DomainName}
CreateCustomCloudFrontDomain:
Fn::And:
- Fn::Not:
Expand Down Expand Up @@ -148,6 +130,8 @@ resources:
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Enabled
DeletionPolicy: Delete
BucketPolicy:
Type: AWS::S3::BucketPolicy
Expand Down Expand Up @@ -177,21 +161,26 @@ resources:
aws:SecureTransport: false
Bucket: !Ref S3Bucket
LoggingBucket:
Type: "AWS::S3::Bucket"
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${self:service}-${self:custom.stage}-cloudfront-logs-${AWS::AccountId}
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Enabled
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: "AES256"
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerPreferred
LoggingConfiguration:
DestinationBucketName: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsBucket, ssm:/configuration/default/s3/accessLogsBucket}
LogFilePrefix: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsPrefix, ssm:/configuration/default/s3/accessLogsPrefix}
DeletionPolicy: Delete
LoggingBucketPolicy:
Type: "AWS::S3::BucketPolicy"
Expand Down Expand Up @@ -269,17 +258,6 @@ resources:
Logging:
Bucket: !Sub "${LoggingBucket}.s3.amazonaws.com"
Prefix: AWSLogs/CLOUDFRONT/${self:custom.stage}/
Route53DnsRecord:
Type: AWS::Route53::RecordSet
Condition: CreateDnsRecord
Properties:
HostedZoneId: ${self:custom.route53HostedZoneId}
Name: ${self:custom.route53DomainName}
AliasTarget:
DNSName: !GetAtt CloudFrontDistribution.DomainName
HostedZoneId: Z2FDTNDATAQYW2
EvaluateTargetHealth: false
Type: A
CloudFormationHeadersPolicy:
Type: AWS::CloudFront::ResponseHeadersPolicy
Properties:
Expand Down

0 comments on commit 0e09798

Please sign in to comment.