Skip to content

Commit b85b7ef

Browse files
author
claudfuen
committed
Fix shell compatibility and JSON consistency issues
- Remove bash-specific 'pipefail' option from shell command - Convert all JSON.stringify calls to template literals for consistency - Simplify RDS Lambda permission ARN construction - Ensure compatibility with /bin/sh execution environment
1 parent e14fbc7 commit b85b7ef

File tree

1 file changed

+44
-48
lines changed

1 file changed

+44
-48
lines changed

apps/infra/index.ts

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,18 @@ const logGroup = new aws.cloudwatch.LogGroup("pathfinder-logs", {
357357

358358
// ECS needs this role to pull images and write logs
359359
const executionRole = new aws.iam.Role("pathfinder-execution-role", {
360-
assumeRolePolicy: JSON.stringify({
361-
Version: "2012-10-17",
362-
Statement: [
360+
assumeRolePolicy: `{
361+
"Version": "2012-10-17",
362+
"Statement": [
363363
{
364-
Action: "sts:AssumeRole",
365-
Effect: "Allow",
366-
Principal: {
367-
Service: "ecs-tasks.amazonaws.com",
368-
},
369-
},
370-
],
371-
}),
364+
"Action": "sts:AssumeRole",
365+
"Effect": "Allow",
366+
"Principal": {
367+
"Service": "ecs-tasks.amazonaws.com"
368+
}
369+
}
370+
]
371+
}`,
372372
});
373373

374374
new aws.iam.RolePolicyAttachment("pathfinder-execution-role-policy", {
@@ -379,18 +379,18 @@ new aws.iam.RolePolicyAttachment("pathfinder-execution-role-policy", {
379379

380380
// CodeBuild Role for building Docker images inside VPC
381381
const codeBuildRole = new aws.iam.Role("pathfinder-codebuild-role", {
382-
assumeRolePolicy: JSON.stringify({
383-
Version: "2012-10-17",
384-
Statement: [
382+
assumeRolePolicy: `{
383+
"Version": "2012-10-17",
384+
"Statement": [
385385
{
386-
Action: "sts:AssumeRole",
387-
Effect: "Allow",
388-
Principal: {
389-
Service: "codebuild.amazonaws.com",
390-
},
391-
},
392-
],
393-
}),
386+
"Action": "sts:AssumeRole",
387+
"Effect": "Allow",
388+
"Principal": {
389+
"Service": "codebuild.amazonaws.com"
390+
}
391+
}
392+
]
393+
}`,
394394
tags: {
395395
...commonTags,
396396
Name: "pathfinder-codebuild-role",
@@ -911,18 +911,18 @@ const albResponseTimeAlarm = new aws.cloudwatch.MetricAlarm(
911911
const betterStackLambdaRole = new aws.iam.Role(
912912
"pathfinder-better-stack-lambda-role",
913913
{
914-
assumeRolePolicy: JSON.stringify({
915-
Version: "2012-10-17",
916-
Statement: [
914+
assumeRolePolicy: `{
915+
"Version": "2012-10-17",
916+
"Statement": [
917917
{
918-
Action: "sts:AssumeRole",
919-
Effect: "Allow",
920-
Principal: {
921-
Service: "lambda.amazonaws.com",
922-
},
923-
},
924-
],
925-
}),
918+
"Action": "sts:AssumeRole",
919+
"Effect": "Allow",
920+
"Principal": {
921+
"Service": "lambda.amazonaws.com"
922+
}
923+
}
924+
]
925+
}`,
926926
tags: {
927927
...commonTags,
928928
Name: "pathfinder-better-stack-lambda-role",
@@ -945,20 +945,20 @@ new aws.iam.RolePolicyAttachment(
945945
const betterStackLambdaPolicy = new aws.iam.Policy(
946946
"pathfinder-better-stack-lambda-policy",
947947
{
948-
policy: JSON.stringify({
949-
Version: "2012-10-17",
950-
Statement: [
948+
policy: `{
949+
"Version": "2012-10-17",
950+
"Statement": [
951951
{
952-
Effect: "Allow",
953-
Action: [
952+
"Effect": "Allow",
953+
"Action": [
954954
"logs:CreateLogGroup",
955955
"logs:CreateLogStream",
956-
"logs:PutLogEvents",
956+
"logs:PutLogEvents"
957957
],
958-
Resource: "arn:aws:logs:*:*:*",
959-
},
960-
],
961-
}),
958+
"Resource": "arn:aws:logs:*:*:*"
959+
}
960+
]
961+
}`,
962962
tags: {
963963
...commonTags,
964964
Name: "pathfinder-better-stack-lambda-policy",
@@ -1080,11 +1080,7 @@ const betterStackLambdaPermissionRDS = new aws.lambda.Permission(
10801080
action: "lambda:InvokeFunction",
10811081
function: betterStackLambda.name,
10821082
principal: "logs.amazonaws.com",
1083-
sourceArn: pulumi.interpolate`arn:aws:logs:${aws.config.region}:${aws
1084-
.getCallerIdentity()
1085-
.then((id) => id.accountId)}:log-group:/aws/rds/instance/${
1086-
db.id
1087-
}/postgresql:*`,
1083+
sourceArn: pulumi.interpolate`${rdsLogGroup.arn}:*`,
10881084
}
10891085
);
10901086

0 commit comments

Comments
 (0)