Skip to content

Commit

Permalink
fix: korjaa cdk-skriptit, jotka alkoivat hajota SIGSEGV-virheeseen Ma…
Browse files Browse the repository at this point in the history
…cOS Ventura-käyttöjärjestelmäversiolla (#521)
  • Loading branch information
haapamakim authored Dec 27, 2022
1 parent 5a0b1f6 commit d4aa173
Show file tree
Hide file tree
Showing 8 changed files with 10,179 additions and 13,532 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17
lts/Fermium
2 changes: 1 addition & 1 deletion cdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "npx ts-node --prefer-ts-exts deployment/bin/hassu.ts",
"app": "./node_modules/.bin/ts-node --prefer-ts-exts deployment/bin/hassu.ts",
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
Expand Down
25 changes: 12 additions & 13 deletions deployment/lib/setupEnvironment.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* tslint:disable:no-console */
// This script examines stack outputs and parameter store parameters, and writes .env.local and .env.test files

import { CloudFormationClient, DescribeStacksCommand, DescribeStacksCommandOutput } from "@aws-sdk/client-cloudformation";
import { GetParametersByPathCommand, GetParametersByPathCommandOutput, SSMClient } from "@aws-sdk/client-ssm";
import Cloudformation, { DescribeStacksOutput } from "aws-sdk/clients/cloudformation";
import SSM, { GetParametersByPathResult } from "aws-sdk/clients/ssm";
import { BaseConfig } from "../../common/BaseConfig";
import { BackendStackOutputs } from "./hassu-backend";
import { DatabaseStackOutputs } from "./hassu-database";
import { FrontendStackOutputs } from "./hassu-frontend";
import { PipelineStackOutputs } from "./hassu-pipelines";
import { AccountStackOutputs } from "./hassu-account";

const usEastCFClient = new CloudFormationClient({ region: "us-east-1" });
const euWestCFClient = new CloudFormationClient({ region: "eu-west-1" });
const usEastCFClient = new Cloudformation({ region: "us-east-1" });
const euWestCFClient = new Cloudformation({ region: "eu-west-1" });

const usEastSSMClient = new SSMClient({ region: "us-east-1" });
const euWestSSMClient = new SSMClient({ region: "eu-west-1" });
const usEastSSMClient = new SSM({ region: "us-east-1" });
const euWestSSMClient = new SSM({ region: "eu-west-1" });

export enum Region {
US_EAST_1,
Expand Down Expand Up @@ -49,14 +48,14 @@ async function readStackOutputsForRawStackName(stackName: string, region: Region
if (!BaseConfig.isActuallyDeployedEnvironment() || BaseConfig.env === "localstack") {
return {};
}
let cfClient;
let cfClient: Cloudformation;
if (region === Region.EU_WEST_1) {
cfClient = euWestCFClient;
} else {
cfClient = usEastCFClient;
}
try {
const output: DescribeStacksCommandOutput = await cfClient.send(new DescribeStacksCommand({ StackName: stackName }));
const output: DescribeStacksOutput = await cfClient.describeStacks({ StackName: stackName }).promise();
return (
output.Stacks?.[0].Outputs?.reduce((params, param) => {
// Include only non-null values. Exclude automatically generated outputs by CDK
Expand Down Expand Up @@ -109,7 +108,7 @@ export type HassuSSMParameters = {
};

export async function readParametersByPath(path: string, region: Region): Promise<Record<string, string>> {
let ssmClient: SSMClient;
let ssmClient: SSM;
if (region === Region.EU_WEST_1) {
ssmClient = euWestSSMClient;
} else {
Expand All @@ -119,9 +118,9 @@ export async function readParametersByPath(path: string, region: Region): Promis
let nextToken;
do {
// noinspection JSUnusedAssignment
const output: GetParametersByPathCommandOutput = await ssmClient.send(
new GetParametersByPathCommand({ Path: path, WithDecryption: true, NextToken: nextToken })
);
const output: GetParametersByPathResult = await ssmClient
.getParametersByPath({ Path: path, WithDecryption: true, NextToken: nextToken })
.promise();
output.Parameters?.forEach((param) => {
if (param.Name && param.Value) {
variables[param.Name.replace(path, "")] = param.Value;
Expand Down
8 changes: 7 additions & 1 deletion deployment/localstack/localstack-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ Resources:
- Action:
- s3:GetObject*
- s3:GetBucket*
- s3:GetEncryptionConfiguration
- s3:List*
- s3:DeleteObject*
- s3:PutObject*
Expand Down Expand Up @@ -377,6 +378,7 @@ Resources:
- cloudformation:DeleteStack
- cloudformation:UpdateTerminationProtection
- sts:GetCallerIdentity
- cloudformation:GetTemplateSummary
Resource: "*"
Effect: Allow
- Sid: CliStagingBucket
Expand Down Expand Up @@ -427,7 +429,7 @@ Resources:
Type: String
Name:
Fn::Sub: /cdk-bootstrap/${Qualifier}/version
Value: "8"
Value: "14"
Outputs:
BucketName:
Description: The name of the S3 bucket owned by the CDK toolkit stack
Expand All @@ -447,6 +449,10 @@ Outputs:
Export:
Name:
Fn::Sub: CdkBootstrap-${Qualifier}-FileAssetKeyArn
ImageRepositoryName:
Description: The name of the ECR repository which hosts docker image assets
Value:
Fn::Sub: ${ContainerAssetsRepository}
BootstrapVersion:
Description: The version of the bootstrap resources that are currently mastered in this stack
Value:
Expand Down
Loading

0 comments on commit d4aa173

Please sign in to comment.