@guardian/cdk 49.1.0-beta.1 → 49.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/constructs/autoscaling/asg.d.ts +3 -2
  2. package/lib/constructs/autoscaling/asg.d.ts.map +1 -1
  3. package/lib/constructs/autoscaling/asg.js.map +1 -1
  4. package/lib/constructs/autoscaling/user-data.js +1 -1
  5. package/lib/constructs/autoscaling/user-data.js.map +1 -1
  6. package/lib/constructs/iam/policies/index.d.ts +0 -1
  7. package/lib/constructs/iam/policies/index.d.ts.map +1 -1
  8. package/lib/constructs/iam/policies/index.js +0 -1
  9. package/lib/constructs/iam/policies/index.js.map +1 -1
  10. package/lib/constructs/iam/roles/instance-role.d.ts.map +1 -1
  11. package/lib/constructs/iam/roles/instance-role.js +2 -1
  12. package/lib/constructs/iam/roles/instance-role.js.map +1 -1
  13. package/lib/constructs/s3/index.d.ts +0 -90
  14. package/lib/constructs/s3/index.d.ts.map +1 -1
  15. package/lib/constructs/s3/index.js +1 -33
  16. package/lib/constructs/s3/index.js.map +1 -1
  17. package/lib/experimental/riff-raff-yaml-file/deployments/cloudformation.d.ts +1 -1
  18. package/lib/experimental/riff-raff-yaml-file/deployments/cloudformation.d.ts.map +1 -1
  19. package/lib/experimental/riff-raff-yaml-file/deployments/cloudformation.js +19 -11
  20. package/lib/experimental/riff-raff-yaml-file/deployments/cloudformation.js.map +1 -1
  21. package/lib/experimental/riff-raff-yaml-file/index.d.ts +10 -22
  22. package/lib/experimental/riff-raff-yaml-file/index.d.ts.map +1 -1
  23. package/lib/experimental/riff-raff-yaml-file/index.js +22 -62
  24. package/lib/experimental/riff-raff-yaml-file/index.js.map +1 -1
  25. package/lib/experimental/riff-raff-yaml-file/types.d.ts +1 -1
  26. package/lib/experimental/riff-raff-yaml-file/types.d.ts.map +1 -1
  27. package/lib/experimental/riff-raff-yaml-file/types.js.map +1 -1
  28. package/lib/patterns/ec2-app/base.d.ts +2 -1
  29. package/lib/patterns/ec2-app/base.d.ts.map +1 -1
  30. package/lib/patterns/ec2-app/base.js.map +1 -1
  31. package/lib/types/amigo.d.ts +5 -0
  32. package/lib/types/amigo.d.ts.map +1 -0
  33. package/lib/types/amigo.js +3 -0
  34. package/lib/types/amigo.js.map +1 -0
  35. package/package.json +21 -21
  36. package/lib/constructs/iam/policies/ssm.d.ts +0 -8
  37. package/lib/constructs/iam/policies/ssm.d.ts.map +0 -1
  38. package/lib/constructs/iam/policies/ssm.js +0 -37
  39. package/lib/constructs/iam/policies/ssm.js.map +0 -1
  40. package/lib/experimental/riff-raff-yaml-file/deployments/s3.d.ts +0 -4
  41. package/lib/experimental/riff-raff-yaml-file/deployments/s3.d.ts.map +0 -1
  42. package/lib/experimental/riff-raff-yaml-file/deployments/s3.js +0 -48
  43. package/lib/experimental/riff-raff-yaml-file/deployments/s3.js.map +0 -1
@@ -4,11 +4,12 @@ import { UserData } from "aws-cdk-lib/aws-ec2";
4
4
  import type { ISecurityGroup } from "aws-cdk-lib/aws-ec2";
5
5
  import type { ApplicationTargetGroup } from "aws-cdk-lib/aws-elasticloadbalancingv2";
6
6
  import type { GuAsgCapacity } from "../../types";
7
+ import type { AmigoProps } from "../../types/amigo";
7
8
  import { GuAmiParameter } from "../core";
8
9
  import type { AppIdentity, GuStack } from "../core";
9
10
  export interface GuAutoScalingGroupProps extends Omit<AutoScalingGroupProps, "imageId" | "osType" | "machineImage" | "userData" | "minCapacity" | "maxCapacity" | "desiredCapacity" | "requireImdsv2" | "securityGroup">, AppIdentity, GuAsgCapacity {
10
11
  imageId?: GuAmiParameter;
11
- imageRecipe?: string;
12
+ imageRecipe?: string | AmigoProps;
12
13
  userData: UserData | string;
13
14
  additionalSecurityGroups?: ISecurityGroup[];
14
15
  targetGroup?: ApplicationTargetGroup;
@@ -42,7 +43,7 @@ declare const GuAutoScalingGroup_base: {
42
43
  export declare class GuAutoScalingGroup extends GuAutoScalingGroup_base {
43
44
  readonly app: string;
44
45
  readonly amiParameter: GuAmiParameter;
45
- readonly imageRecipe?: string;
46
+ readonly imageRecipe?: string | AmigoProps;
46
47
  constructor(scope: GuStack, id: string, props: GuAutoScalingGroupProps);
47
48
  }
48
49
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"asg.d.ts","sourceRoot":"","sources":["../../../src/constructs/autoscaling/asg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAuB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAOpD,MAAM,WAAW,uBACf,SAAQ,IAAI,CACR,qBAAqB,EACnB,SAAS,GACT,QAAQ,GACR,cAAc,GACd,UAAU,GACV,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,eAAe,GACf,eAAe,CAClB,EACD,WAAW,EACX,aAAa;IACf,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5C,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;;;;;;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,kBAAmB,SAAQ,uBAAqC;IAC3E,SAAgB,GAAG,EAAE,MA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ws-autoscaling\";\nimport type { AutoScalingGroupProps, CfnAutoScalingGroup } from \"aws-cdk-lib/aws-autoscaling\";\nimport { OperatingSystemType, UserData } from \"aws-cdk-lib/aws-ec2\";\nimport type { ISecurityGroup, MachineImageConfig } from \"aws-cdk-lib/aws-ec2\";\nimport type { ApplicationTargetGroup } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport type { GuAsgCapacity } from \"../../types\";\nimport { GuAppAwareConstruct } from \"../../utils/mixin/app-aware-construct\";\nimport { GuAmiParameter } from \"../core\";\nimport type { AppIdentity, GuStack } from \"../core\";\nimport { GuHttpsEgressSecurityGroup, GuWazuhAccess } from \"../ec2\";\nimport { GuInstanceRole } from \"../iam\";\n\n// Since we want to override the types of what gets passed in for the below props,\n// we need to use Omit<T, U> to remove them from the interface this extends\n// https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys\nexport interface GuAutoScalingGroupProps\n extends Omit<\n AutoScalingGroupProps,\n | \"imageId\"\n | \"osType\"\n | \"machineImage\"\n | \"userData\"\n | \"minCapacity\"\n | \"maxCapacity\"\n | \"desiredCapacity\"\n | \"requireImdsv2\"\n | \"securityGroup\"\n >,\n AppIdentity,\n GuAsgCapacity {\n imageId?: GuAmiParameter;\n imageRecipe?: string;\n userData: UserData | string;\n additionalSecurityGroups?: ISecurityGroup[];\n targetGroup?: ApplicationTargetGroup;\n withoutImdsv2?: boolean;\n}\n\n/**\n * Construct which creates an Auto Scaling group.\n *\n * By default, all EC2 instances in this group will use [[`GuInstanceRole`]],\n * which provides common permissions (e.g. the ability to download an artifact and write logs to the account's logging Kinesis stream).\n *\n * If additional IAM permissions are required, a custom role can be provided via the `role` prop.\n * You may wish to instantiate [[`GuInstanceRole`]] yourself as a basis for this custom role, as it allows custom permissions\n * to be passed in.\n *\n * All EC2 instances in this group will be automatically associated with two security groups:\n * 1. [[`GuHttpsEgressSecurityGroup`]], which allows outbound traffic over HTTPS.\n * 2. [[`GuWazuhAccess`]], which allows instances to communicate with Wazuh (for security monitoring).\n *\n * If additional ingress or egress rules are required, define custom security groups and pass them in via the\n * `additionalSecurityGroups` prop.\n *\n * All EC2 instances provisioned via this construct will use\n * [IMDSv2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).\n */\nexport class GuAutoScalingGroup extends GuAppAwareConstruct(AutoScalingGroup) {\n public readonly app: string;\n public readonly amiParameter: GuAmiParameter;\n public readonly imageRecipe?: string;\n\n constructor(scope: GuStack, id: string, props: GuAutoScalingGroupProps) {\n const {\n app,\n additionalSecurityGroups = [],\n imageId = new GuAmiParameter(scope, { app }),\n imageRecipe,\n minimumInstances,\n maximumInstances,\n role = new GuInstanceRole(scope, { app }),\n targetGroup,\n userData: userDataLike,\n vpc,\n withoutImdsv2 = false,\n } = props;\n\n // Ensure min and max are defined in the same way. Throwing an `Error` when necessary. For example when min is defined via a Mapping, but max is not.\n if (Token.isUnresolved(minimumInstances) && !Token.isUnresolved(maximumInstances)) {\n throw new Error(\n \"minimumInstances is defined via a Mapping, but maximumInstances is not. Create maximumInstances via a Mapping too.\"\n );\n }\n\n const userData = userDataLike instanceof UserData ? userDataLike : UserData.custom(userDataLike);\n\n const mergedProps: AutoScalingGroupProps = {\n ...props,\n minCapacity: minimumInstances,\n maxCapacity: maximumInstances ?? minimumInstances * 2,\n role,\n requireImdsv2: !withoutImdsv2,\n machineImage: {\n getImage: (): MachineImageConfig => {\n return {\n osType: OperatingSystemType.LINUX,\n userData,\n imageId: imageId.valueAsString,\n };\n },\n },\n userData,\n // Do not use the default AWS security group which allows egress on any port.\n // Favour HTTPS only egress rules by default.\n securityGroup: GuHttpsEgressSecurityGroup.forVpc(scope, { app, vpc }),\n };\n\n super(scope, id, mergedProps);\n this.app = app;\n this.amiParameter = imageId;\n this.imageRecipe = imageRecipe;\n\n targetGroup && this.attachToApplicationTargetGroup(targetGroup);\n\n [GuWazuhAccess.getInstance(scope, vpc), ...additionalSecurityGroups].forEach((sg) => this.addSecurityGroup(sg));\n\n const cfnAsg = this.node.defaultChild as CfnAutoScalingGroup;\n // A CDK AutoScalingGroup comes with this update policy, whereas the CFN autscaling group\n // leaves it to the default value, which is actually false.\n // { UpdatePolicy: { autoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: true }}\n cfnAsg.addDeletionOverride(\"UpdatePolicy\");\n }\n}\n"]}
1
+ {"version":3,"file":"asg.js","sourceRoot":"","sources":["../../../src/constructs/autoscaling/asg.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AACpC,iEAA+D;AAE/D,iDAAoE;AAKpE,+EAA4E;AAC5E,kCAAyC;AAEzC,gCAAmE;AACnE,gCAAwC;AA4BxC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,kBAAmB,SAAQ,IAAA,yCAAmB,EAAC,kCAAgB,CAAC;IAK3E,YAAY,KAAc,EAAE,EAAU,EAAE,KAA8B;QACpE,MAAM,EACJ,GAAG,EACH,wBAAwB,GAAG,EAAE,EAC7B,OAAO,GAAG,IAAI,qBAAc,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAC5C,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,IAAI,GAAG,IAAI,oBAAc,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EACzC,WAAW,EACX,QAAQ,EAAE,YAAY,EACtB,GAAG,EACH,aAAa,GAAG,KAAK,GACtB,GAAG,KAAK,CAAC;QAEV,qJAAqJ;QACrJ,IAAI,mBAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,mBAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE;YACjF,MAAM,IAAI,KAAK,CACb,oHAAoH,CACrH,CAAC;SACH;QAED,MAAM,QAAQ,GAAG,YAAY,YAAY,kBAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAEjG,MAAM,WAAW,GAA0B;YACzC,GAAG,KAAK;YACR,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,gBAAgB,IAAI,gBAAgB,GAAG,CAAC;YACrD,IAAI;YACJ,aAAa,EAAE,CAAC,aAAa;YAC7B,YAAY,EAAE;gBACZ,QAAQ,EAAE,GAAuB,EAAE;oBACjC,OAAO;wBACL,MAAM,EAAE,6BAAmB,CAAC,KAAK;wBACjC,QAAQ;wBACR,OAAO,EAAE,OAAO,CAAC,aAAa;qBAC/B,CAAC;gBACJ,CAAC;aACF;YACD,QAAQ;YACR,6EAA6E;YAC7E,6CAA6C;YAC7C,aAAa,EAAE,gCAA0B,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;SACtE,CAAC;QAEF,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,WAAW,IAAI,IAAI,CAAC,8BAA8B,CAAC,WAAW,CAAC,CAAC;QAEhE,CAAC,mBAAa,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;QAEhH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAmC,CAAC;QAC7D,yFAAyF;QACzF,2DAA2D;QAC3D,+FAA+F;QAC/F,MAAM,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;CACF;AAjED,gDAiEC","sourcesContent":["import { Token } from \"aws-cdk-lib\";\nimport { AutoScalingGroup } from \"aws-cdk-lib/aws-autoscaling\";\nimport type { AutoScalingGroupProps, CfnAutoScalingGroup } from \"aws-cdk-lib/aws-autoscaling\";\nimport { OperatingSystemType, UserData } from \"aws-cdk-lib/aws-ec2\";\nimport type { ISecurityGroup, MachineImageConfig } from \"aws-cdk-lib/aws-ec2\";\nimport type { ApplicationTargetGroup } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport type { GuAsgCapacity } from \"../../types\";\nimport type { AmigoProps } from \"../../types/amigo\";\nimport { GuAppAwareConstruct } from \"../../utils/mixin/app-aware-construct\";\nimport { GuAmiParameter } from \"../core\";\nimport type { AppIdentity, GuStack } from \"../core\";\nimport { GuHttpsEgressSecurityGroup, GuWazuhAccess } from \"../ec2\";\nimport { GuInstanceRole } from \"../iam\";\n\n// Since we want to override the types of what gets passed in for the below props,\n// we need to use Omit<T, U> to remove them from the interface this extends\n// https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys\nexport interface GuAutoScalingGroupProps\n extends Omit<\n AutoScalingGroupProps,\n | \"imageId\"\n | \"osType\"\n | \"machineImage\"\n | \"userData\"\n | \"minCapacity\"\n | \"maxCapacity\"\n | \"desiredCapacity\"\n | \"requireImdsv2\"\n | \"securityGroup\"\n >,\n AppIdentity,\n GuAsgCapacity {\n imageId?: GuAmiParameter;\n imageRecipe?: string | AmigoProps;\n userData: UserData | string;\n additionalSecurityGroups?: ISecurityGroup[];\n targetGroup?: ApplicationTargetGroup;\n withoutImdsv2?: boolean;\n}\n\n/**\n * Construct which creates an Auto Scaling group.\n *\n * By default, all EC2 instances in this group will use [[`GuInstanceRole`]],\n * which provides common permissions (e.g. the ability to download an artifact and write logs to the account's logging Kinesis stream).\n *\n * If additional IAM permissions are required, a custom role can be provided via the `role` prop.\n * You may wish to instantiate [[`GuInstanceRole`]] yourself as a basis for this custom role, as it allows custom permissions\n * to be passed in.\n *\n * All EC2 instances in this group will be automatically associated with two security groups:\n * 1. [[`GuHttpsEgressSecurityGroup`]], which allows outbound traffic over HTTPS.\n * 2. [[`GuWazuhAccess`]], which allows instances to communicate with Wazuh (for security monitoring).\n *\n * If additional ingress or egress rules are required, define custom security groups and pass them in via the\n * `additionalSecurityGroups` prop.\n *\n * All EC2 instances provisioned via this construct will use\n * [IMDSv2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).\n */\nexport class GuAutoScalingGroup extends GuAppAwareConstruct(AutoScalingGroup) {\n public readonly app: string;\n public readonly amiParameter: GuAmiParameter;\n public readonly imageRecipe?: string | AmigoProps;\n\n constructor(scope: GuStack, id: string, props: GuAutoScalingGroupProps) {\n const {\n app,\n additionalSecurityGroups = [],\n imageId = new GuAmiParameter(scope, { app }),\n imageRecipe,\n minimumInstances,\n maximumInstances,\n role = new GuInstanceRole(scope, { app }),\n targetGroup,\n userData: userDataLike,\n vpc,\n withoutImdsv2 = false,\n } = props;\n\n // Ensure min and max are defined in the same way. Throwing an `Error` when necessary. For example when min is defined via a Mapping, but max is not.\n if (Token.isUnresolved(minimumInstances) && !Token.isUnresolved(maximumInstances)) {\n throw new Error(\n \"minimumInstances is defined via a Mapping, but maximumInstances is not. Create maximumInstances via a Mapping too.\"\n );\n }\n\n const userData = userDataLike instanceof UserData ? userDataLike : UserData.custom(userDataLike);\n\n const mergedProps: AutoScalingGroupProps = {\n ...props,\n minCapacity: minimumInstances,\n maxCapacity: maximumInstances ?? minimumInstances * 2,\n role,\n requireImdsv2: !withoutImdsv2,\n machineImage: {\n getImage: (): MachineImageConfig => {\n return {\n osType: OperatingSystemType.LINUX,\n userData,\n imageId: imageId.valueAsString,\n };\n },\n },\n userData,\n // Do not use the default AWS security group which allows egress on any port.\n // Favour HTTPS only egress rules by default.\n securityGroup: GuHttpsEgressSecurityGroup.forVpc(scope, { app, vpc }),\n };\n\n super(scope, id, mergedProps);\n this.app = app;\n this.amiParameter = imageId;\n this.imageRecipe = imageRecipe;\n\n targetGroup && this.attachToApplicationTargetGroup(targetGroup);\n\n [GuWazuhAccess.getInstance(scope, vpc), ...additionalSecurityGroups].forEach((sg) => this.addSecurityGroup(sg));\n\n const cfnAsg = this.node.defaultChild as CfnAutoScalingGroup;\n // A CDK AutoScalingGroup comes with this update policy, whereas the CFN autscaling group\n // leaves it to the default value, which is actually false.\n // { UpdatePolicy: { autoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: true }}\n cfnAsg.addDeletionOverride(\"UpdatePolicy\");\n }\n}\n"]}
@@ -18,7 +18,7 @@ class GuUserData {
18
18
  }
19
19
  downloadDistributable(scope, app, props) {
20
20
  const bucketKey = types_1.GuDistributable.getObjectKey(scope, app, props);
21
- const bucket = aws_s3_1.Bucket.fromBucketAttributes(scope, "DistributionBucket", {
21
+ const bucket = aws_s3_1.Bucket.fromBucketAttributes(scope, `DistributionBucket-${app.app}`, {
22
22
  bucketName: core_1.GuDistributionBucketParameter.getInstance(scope).valueAsString,
23
23
  });
24
24
  this.addS3DownloadCommand({
@@ -1 +1 @@
1
- {"version":3,"file":"user-data.js","sourceRoot":"","sources":["../../../src/constructs/autoscaling/user-data.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAE/C,+CAA4C;AAC5C,uCAA8C;AAG9C,kCAAwD;AASxD;;;;;;GAMG;AACH,MAAa,UAAU;IAGrB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,qBAAqB,CAAC,KAAc,EAAE,GAAgB,EAAE,KAA4B;QAC1F,MAAM,SAAS,GAAG,uBAAe,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAElE,MAAM,MAAM,GAAG,eAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,EAAE;YACtE,UAAU,EAAE,oCAA6B,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,aAAa;SAC3E,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,CAAC;YACxB,MAAM;YACN,SAAS;YACT,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE;SAC3C,CAAC,CAAC;IACL,CAA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QAC5C,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9DD,gCA8DC","sourcesContent":["import { UserData } from \"aws-cdk-lib/aws-ec2\";\nimport type { S3DownloadOptions } from \"aws-cdk-lib/aws-ec2\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { GuDistributable } from \"../../types\";\nimport type { GuDistributableForEc2 } from \"../../types\";\nimport type { GuPrivateS3ConfigurationProps } from \"../../utils/ec2\";\nimport { GuDistributionBucketParameter } from \"../core\";\nimport type { AppIdentity, GuStack } from \"../core\";\n\nexport type GuUserDataPropsWithApp = GuUserDataProps & AppIdentity;\nexport interface GuUserDataProps {\n distributable: GuDistributableForEc2;\n configuration?: GuPrivateS3ConfigurationProps;\n}\n\n/**\n * An abstraction over UserData to simplify its creation.\n * Especially useful for simple user data where we:\n * - (optional) download config\n * - download distributable\n * - execute distributable\n */\nexport class GuUserData {\n private readonly _userData: UserData;\n\n get userData(): UserData {\n return this._userData;\n }\n\n private downloadDistributable(scope: GuStack, app: AppIdentity, props: GuDistributableForEc2) {\n const bucketKey = GuDistributable.getObjectKey(scope, app, props);\n\n const bucket = Bucket.fromBucketAttributes(scope, \"DistributionBucket\", {\n bucketName: GuDistributionBucketParameter.getInstance(scope).valueAsString,\n });\n\n this.addS3DownloadCommand({\n bucket,\n bucketKey,\n localFile: `/${app.app}/${props.fileName}`,\n });\n }\n\n private downloadConfiguration(scope: GuStack, app: string, props: GuPrivateS3ConfigurationProps) {\n const bucket = Bucket.fromBucketAttributes(scope, `${app}ConfigurationBucket`, {\n bucketName: props.bucket.valueAsString,\n });\n\n props.files.forEach((bucketKey) => {\n const fileName = bucketKey.split(\"/\").slice(-1)[0];\n\n // `fileName` is typed as `string | undefined`. Throw if `fileName` is falsy.\n if (!fileName) {\n throw new Error(\"Failed to create configuration section in UserData\");\n }\n\n this.addS3DownloadCommand({\n bucket,\n bucketKey,\n localFile: `/etc/${app}/${fileName}`,\n });\n });\n }\n\n constructor(scope: GuStack, props: GuUserDataPropsWithApp) {\n this._userData = UserData.forLinux();\n\n if (props.configuration) {\n this.downloadConfiguration(scope, props.app, props.configuration);\n }\n\n this.downloadDistributable(scope, props, props.distributable);\n this.addCommands(props.distributable.executionStatement);\n }\n\n addCommands(...commands: string[]): GuUserData {\n this._userData.addCommands(...commands);\n return this;\n }\n\n addS3DownloadCommand(params: S3DownloadOptions): GuUserData {\n this._userData.addS3DownloadCommand(params);\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"user-data.js","sourceRoot":"","sources":["../../../src/constructs/autoscaling/user-data.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAE/C,+CAA4C;AAC5C,uCAA8C;AAG9C,kCAAwD;AASxD;;;;;;GAMG;AACH,MAAa,UAAU;IAGrB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,qBAAqB,CAAC,KAAc,EAAE,GAAgB,EAAE,KAA4B;QAC1F,MAAM,SAAS,GAAG,uBAAe,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAElE,MAAM,MAAM,GAAG,eAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,sBAAsB,GAAG,CAAC,GAAG,EAAE,EAAE;YACjF,UAAU,EAAE,oCAA6B,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,aAAa;SAC3E,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,CAAC;YACxB,MAAM;YACN,SAAS;YACT,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE;SAC3C,CAAC,CAAC;IACL,CAAC;IAEO,qBAAqB,CAAC,KAAc,EAAE,GAAW,EAAE,KAAoC;QAC7F,MAAM,MAAM,GAAG,eAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,qBAAqB,EAAE;YAC7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lib/aws-ec2\";\nimport type { S3DownloadOptions } from \"aws-cdk-lib/aws-ec2\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { GuDistributable } from \"../../types\";\nimport type { GuDistributableForEc2 } from \"../../types\";\nimport type { GuPrivateS3ConfigurationProps } from \"../../utils/ec2\";\nimport { GuDistributionBucketParameter } from \"../core\";\nimport type { AppIdentity, GuStack } from \"../core\";\n\nexport type GuUserDataPropsWithApp = GuUserDataProps & AppIdentity;\nexport interface GuUserDataProps {\n distributable: GuDistributableForEc2;\n configuration?: GuPrivateS3ConfigurationProps;\n}\n\n/**\n * An abstraction over UserData to simplify its creation.\n * Especially useful for simple user data where we:\n * - (optional) download config\n * - download distributable\n * - execute distributable\n */\nexport class GuUserData {\n private readonly _userData: UserData;\n\n get userData(): UserData {\n return this._userData;\n }\n\n private downloadDistributable(scope: GuStack, app: AppIdentity, props: GuDistributableForEc2) {\n const bucketKey = GuDistributable.getObjectKey(scope, app, props);\n\n const bucket = Bucket.fromBucketAttributes(scope, `DistributionBucket-${app.app}`, {\n bucketName: GuDistributionBucketParameter.getInstance(scope).valueAsString,\n });\n\n this.addS3DownloadCommand({\n bucket,\n bucketKey,\n localFile: `/${app.app}/${props.fileName}`,\n });\n }\n\n private downloadConfiguration(scope: GuStack, app: string, props: GuPrivateS3ConfigurationProps) {\n const bucket = Bucket.fromBucketAttributes(scope, `${app}ConfigurationBucket`, {\n bucketName: props.bucket.valueAsString,\n });\n\n props.files.forEach((bucketKey) => {\n const fileName = bucketKey.split(\"/\").slice(-1)[0];\n\n // `fileName` is typed as `string | undefined`. Throw if `fileName` is falsy.\n if (!fileName) {\n throw new Error(\"Failed to create configuration section in UserData\");\n }\n\n this.addS3DownloadCommand({\n bucket,\n bucketKey,\n localFile: `/etc/${app}/${fileName}`,\n });\n });\n }\n\n constructor(scope: GuStack, props: GuUserDataPropsWithApp) {\n this._userData = UserData.forLinux();\n\n if (props.configuration) {\n this.downloadConfiguration(scope, props.app, props.configuration);\n }\n\n this.downloadDistributable(scope, props, props.distributable);\n this.addCommands(props.distributable.executionStatement);\n }\n\n addCommands(...commands: string[]): GuUserData {\n this._userData.addCommands(...commands);\n return this;\n }\n\n addS3DownloadCommand(params: S3DownloadOptions): GuUserData {\n this._userData.addS3DownloadCommand(params);\n return this;\n }\n}\n"]}
@@ -9,5 +9,4 @@ export * from "./parameter-store-read";
9
9
  export * from "./s3-get-object";
10
10
  export * from "./s3-put-object";
11
11
  export * from "./ses";
12
- export * from "./ssm";
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC"}
@@ -25,5 +25,4 @@ __exportStar(require("./parameter-store-read"), exports);
25
25
  __exportStar(require("./s3-get-object"), exports);
26
26
  __exportStar(require("./s3-put-object"), exports);
27
27
  __exportStar(require("./ses"), exports);
28
- __exportStar(require("./ssm"), exports);
29
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,iDAA+B;AAC/B,yDAAuC;AACvC,kDAAgC;AAChC,kDAAgC;AAChC,wCAAsB;AACtB,wCAAsB","sourcesContent":["export * from \"./anghammarad\";\nexport * from \"./assume-role\";\nexport * from \"./base-policy\";\nexport * from \"./cloudwatch\";\nexport * from \"./describe-ec2\";\nexport * from \"./dynamodb\";\nexport * from \"./log-shipping\";\nexport * from \"./parameter-store-read\";\nexport * from \"./s3-get-object\";\nexport * from \"./s3-put-object\";\nexport * from \"./ses\";\nexport * from \"./ssm\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,iDAA+B;AAC/B,yDAAuC;AACvC,kDAAgC;AAChC,kDAAgC;AAChC,wCAAsB","sourcesContent":["export * from \"./anghammarad\";\nexport * from \"./assume-role\";\nexport * from \"./base-policy\";\nexport * from \"./cloudwatch\";\nexport * from \"./describe-ec2\";\nexport * from \"./dynamodb\";\nexport * from \"./log-shipping\";\nexport * from \"./parameter-store-read\";\nexport * from \"./s3-get-object\";\nexport * from \"./s3-put-object\";\nexport * from \"./ses\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"instance-role.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/roles/instance-role.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;CACjC;AAED,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,GAAG,WAAW,CAAC;;;;;;AAE3E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,SAAQ,mBAA2B;gBACjD,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,0BAA0B;CAsB9D"}
1
+ {"version":3,"file":"instance-role.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/roles/instance-role.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAOvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;CACjC;AAED,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,GAAG,WAAW,CAAC;;;;;;AAE3E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,SAAQ,mBAA2B;gBACjD,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,0BAA0B;CAwB9D"}
@@ -28,7 +28,6 @@ class GuInstanceRole extends (0, app_aware_construct_1.GuAppAwareConstruct)(role
28
28
  ...props,
29
29
  });
30
30
  const sharedPolicies = [
31
- policies_1.GuSSMRunCommandPolicy.getInstance(scope),
32
31
  policies_1.GuDescribeEC2Policy.getInstance(scope),
33
32
  ...(props.withoutLogShipping ? [] : [policies_1.GuLogShippingPolicy.getInstance(scope)]),
34
33
  ];
@@ -38,7 +37,9 @@ class GuInstanceRole extends (0, app_aware_construct_1.GuAppAwareConstruct)(role
38
37
  new policies_1.GuParameterStoreReadPolicy(scope, props),
39
38
  ...(props.additionalPolicies ? props.additionalPolicies : []),
40
39
  ];
40
+ const managedPolicies = [aws_iam_1.ManagedPolicy.fromAwsManagedPolicyName("AmazonSSMManagedInstanceCore")];
41
41
  policies.forEach((p) => p.attachToRole(this));
42
+ managedPolicies.forEach((p) => this.addManagedPolicy(p));
42
43
  }
43
44
  }
44
45
  exports.GuInstanceRole = GuInstanceRole;
@@ -1 +1 @@
1
- {"version":3,"file":"instance-role.js","sourceRoot":"","sources":["../../../../src/constructs/iam/roles/instance-role.ts"],"names":[],"mappings":";;;AAAA,iDAAuD;AACvD,kFAA+E;AAE/E,0CAMqB;AAErB,mCAAiC;AAgBjC;;;;;;;;;;;;;;GAcG;AACH,MAAa,cAAe,SAAQ,IAAA,yCAAmB,EAAC,cAAM,CAAC;IAC7D,YAAY,KAAc,EAAE,KAAiC;QAC3D,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE;YAC3B,IAAI,EAAE,GAAG;YACT,SAAS,EAAE,IAAI,0BAAgB,CAAC,mBAAmB,CAAC;YACpD,GAAG,KAAK;SACT,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG;YACrB,gCAAqB,CAAC,WAAW,CAAC,KAAK,CAAC;YACxC,8BAAmB,CAAC,WAAW,CAAC,KAAK,CAAC;YACtC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,8BAAmB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAC9E,CAAC;QAEF,MAAM,QAAQ,GAAG;YACf,GAAG,cAAc;YACjB,IAAI,mCAAwB,CAAC,KAAK,EAAE,KAAK,CAAC;YAC1C,IAAI,qCAA0B,CAAC,KAAK,EAAE,KAAK,CAAC;YAC5C,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D,CAAC;QAEF,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;CACF;AAvBD,wCAuBC","sourcesContent":["import { ServicePrincipal } from \"aws-cdk-lib/aws-iam\";\nimport { GuAppAwareConstruct } from \"../../../utils/mixin/app-aware-construct\";\nimport type { AppIdentity, GuStack } from \"../../core\";\nimport {\n GuDescribeEC2Policy,\n GuGetDistributablePolicy,\n GuLogShippingPolicy,\n GuParameterStoreReadPolicy,\n GuSSMRunCommandPolicy,\n} from \"../policies\";\nimport type { GuPolicy } from \"../policies\";\nimport { GuRole } from \"./roles\";\n\nexport interface GuInstanceRoleProps {\n /**\n * By default, instances are given permissions to write to Kinesis. Set to\n * 'true' to prevent this. Note, disabling will prevent not just application\n * logs being shipped but also anything else - for example, automatic log\n * shipping of Cloud Init and other logs by the cdk-base role in your AMI.\n */\n withoutLogShipping?: boolean;\n\n additionalPolicies?: GuPolicy[];\n}\n\nexport type GuInstanceRolePropsWithApp = GuInstanceRoleProps & AppIdentity;\n\n/**\n * Creates an IAM role with common policies that are needed by most Guardian applications.\n *\n * More specifically:\n * 1. Allows for `ssh` access to an EC2 instance via [ssm-scala](https://github.com/guardian/ssm-scala) (instead of standard `ssh`).\n * 2. Allows EC2 instances to communicate with Wazuh, for security monitoring.\n * 3. Allows EC2 instances to download an artifact from AWS S3, for application deployment.\n * 4. Allows EC2 instances to download private configuration from AWS Parameter Store. See [[`GuParameterStoreReadPolicy`]]\n * for specific details.\n * 5. Allows EC2 instances to write logs into our central ELK stack via Kinesis.\n *\n * If additional IAM permissions are required, create custom policies and pass them in via the `additionalPolicies` prop.\n *\n * If log shipping is not required, opt out by setting the `withoutLogShipping` prop to `true`.\n */\nexport class GuInstanceRole extends GuAppAwareConstruct(GuRole) {\n constructor(scope: GuStack, props: GuInstanceRolePropsWithApp) {\n super(scope, \"InstanceRole\", {\n path: \"/\",\n assumedBy: new ServicePrincipal(\"ec2.amazonaws.com\"),\n ...props,\n });\n\n const sharedPolicies = [\n GuSSMRunCommandPolicy.getInstance(scope),\n GuDescribeEC2Policy.getInstance(scope),\n ...(props.withoutLogShipping ? [] : [GuLogShippingPolicy.getInstance(scope)]),\n ];\n\n const policies = [\n ...sharedPolicies,\n new GuGetDistributablePolicy(scope, props),\n new GuParameterStoreReadPolicy(scope, props),\n ...(props.additionalPolicies ? props.additionalPolicies : []),\n ];\n\n policies.forEach((p) => p.attachToRole(this));\n }\n}\n"]}
1
+ {"version":3,"file":"instance-role.js","sourceRoot":"","sources":["../../../../src/constructs/iam/roles/instance-role.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,kFAA+E;AAE/E,0CAKqB;AAErB,mCAAiC;AAgBjC;;;;;;;;;;;;;;GAcG;AACH,MAAa,cAAe,SAAQ,IAAA,yCAAmB,EAAC,cAAM,CAAC;IAC7D,YAAY,KAAc,EAAE,KAAiC;QAC3D,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE;YAC3B,IAAI,EAAE,GAAG;YACT,SAAS,EAAE,IAAI,0BAAgB,CAAC,mBAAmB,CAAC;YACpD,GAAG,KAAK;SACT,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG;YACrB,8BAAmB,CAAC,WAAW,CAAC,KAAK,CAAC;YACtC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,8BAAmB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAC9E,CAAC;QAEF,MAAM,QAAQ,GAAG;YACf,GAAG,cAAc;YACjB,IAAI,mCAAwB,CAAC,KAAK,EAAE,KAAK,CAAC;YAC1C,IAAI,qCAA0B,CAAC,KAAK,EAAE,KAAK,CAAC;YAC5C,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,uBAAa,CAAC,wBAAwB,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAEjG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAzBD,wCAyBC","sourcesContent":["import { ManagedPolicy, ServicePrincipal } from \"aws-cdk-lib/aws-iam\";\nimport { GuAppAwareConstruct } from \"../../../utils/mixin/app-aware-construct\";\nimport type { AppIdentity, GuStack } from \"../../core\";\nimport {\n GuDescribeEC2Policy,\n GuGetDistributablePolicy,\n GuLogShippingPolicy,\n GuParameterStoreReadPolicy,\n} from \"../policies\";\nimport type { GuPolicy } from \"../policies\";\nimport { GuRole } from \"./roles\";\n\nexport interface GuInstanceRoleProps {\n /**\n * By default, instances are given permissions to write to Kinesis. Set to\n * 'true' to prevent this. Note, disabling will prevent not just application\n * logs being shipped but also anything else - for example, automatic log\n * shipping of Cloud Init and other logs by the cdk-base role in your AMI.\n */\n withoutLogShipping?: boolean;\n\n additionalPolicies?: GuPolicy[];\n}\n\nexport type GuInstanceRolePropsWithApp = GuInstanceRoleProps & AppIdentity;\n\n/**\n * Creates an IAM role with common policies that are needed by most Guardian applications.\n *\n * More specifically:\n * 1. Allows for `ssh` access to an EC2 instance via [ssm-scala](https://github.com/guardian/ssm-scala) (instead of standard `ssh`).\n * 2. Allows EC2 instances to communicate with Wazuh, for security monitoring.\n * 3. Allows EC2 instances to download an artifact from AWS S3, for application deployment.\n * 4. Allows EC2 instances to download private configuration from AWS Parameter Store. See [[`GuParameterStoreReadPolicy`]]\n * for specific details.\n * 5. Allows EC2 instances to write logs into our central ELK stack via Kinesis.\n *\n * If additional IAM permissions are required, create custom policies and pass them in via the `additionalPolicies` prop.\n *\n * If log shipping is not required, opt out by setting the `withoutLogShipping` prop to `true`.\n */\nexport class GuInstanceRole extends GuAppAwareConstruct(GuRole) {\n constructor(scope: GuStack, props: GuInstanceRolePropsWithApp) {\n super(scope, \"InstanceRole\", {\n path: \"/\",\n assumedBy: new ServicePrincipal(\"ec2.amazonaws.com\"),\n ...props,\n });\n\n const sharedPolicies = [\n GuDescribeEC2Policy.getInstance(scope),\n ...(props.withoutLogShipping ? [] : [GuLogShippingPolicy.getInstance(scope)]),\n ];\n\n const policies = [\n ...sharedPolicies,\n new GuGetDistributablePolicy(scope, props),\n new GuParameterStoreReadPolicy(scope, props),\n ...(props.additionalPolicies ? props.additionalPolicies : []),\n ];\n\n const managedPolicies = [ManagedPolicy.fromAwsManagedPolicyName(\"AmazonSSMManagedInstanceCore\")];\n\n policies.forEach((p) => p.attachToRole(this));\n managedPolicies.forEach((p) => this.addManagedPolicy(p));\n }\n}\n"]}
@@ -1,7 +1,5 @@
1
- import type { Duration } from "aws-cdk-lib";
2
1
  import type { BucketProps } from "aws-cdk-lib/aws-s3";
3
2
  import { Bucket } from "aws-cdk-lib/aws-s3";
4
- import type { IConstruct } from "constructs";
5
3
  import type { AppIdentity, GuStack } from "../core";
6
4
  export interface GuS3BucketProps extends Omit<BucketProps, "removalPolicy">, AppIdentity {
7
5
  }
@@ -16,93 +14,5 @@ declare const GuS3Bucket_base: {
16
14
  export declare class GuS3Bucket extends GuS3Bucket_base {
17
15
  constructor(scope: GuStack, id: string, props: GuS3BucketProps);
18
16
  }
19
- interface GuS3OriginBucketDeploymentProps {
20
- /**
21
- * Customises the SSM Parameter path, making it stage agnostic.
22
- * Useful when a single bucket is used across multiple stages.
23
- *
24
- * When `false` the path will be `/<STAGE>/<STACK>/<APP>/<APP>-origin-bucket`.
25
- * When `true` the path will be `/<STACK>/<APP>/<APP>-origin-bucket`.
26
- *
27
- * @default false
28
- */
29
- withoutStageAwareness: boolean;
30
- /**
31
- * Used to configure `bucketSsmKeyStageParam` in a generated `riff-raff.yaml` file.
32
- *
33
- * The SSM Parameter path, without a stage prefix.
34
- *
35
- * Not settable by user.
36
- *
37
- * @internal
38
- */
39
- baseParameterName: string;
40
- /**
41
- * Used to configure `cacheControl` in a generated `riff-raff.yaml` file.
42
- * Only needed if you're also using {@link GuRootExperimental}.
43
- *
44
- * Set the cache control header for the uploaded files.
45
- *
46
- * The key is a regular expression to match uploaded files.
47
- * The value is the max-age to set in the `Cache-Control` header.
48
- *
49
- * @example
50
- * To cache all files for one hour:
51
- * ```ts
52
- * { ".*", Duration.hours(1) }
53
- * ```
54
- *
55
- * @default cache nothing
56
- * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
57
- */
58
- cacheControl: Record<string, Duration>;
59
- /**
60
- * Used to configure `surrogateControl` in a generated `riff-raff.yaml` file.
61
- * Only needed if you're also using {@link GuRootExperimental}.
62
- *
63
- * Same as [[cacheControl]], but for setting the surrogate-control cache header, which is used by Fastly.
64
- *
65
- * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
66
- */
67
- surrogateControl: Record<string, Duration>;
68
- /**
69
- * Used to configure `mimeTypes` in a generated `riff-raff.yaml` file.
70
- * Only needed if you're also using {@link GuRootExperimental}.
71
- *
72
- * A map of file extension to MIME type.
73
- *
74
- * When a file is uploaded with a file extension that is in this map, the Content-Type header will be set to the MIME type provided.
75
- *
76
- * @example
77
- * ```ts
78
- * { "xpi", "application/x-xpinstall" }
79
- * ```
80
- *
81
- * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
82
- */
83
- mimeTypes: Record<string, string>;
84
- }
85
- export interface GuS3OriginBucketProps extends GuS3BucketProps, Partial<Omit<GuS3OriginBucketDeploymentProps, "baseParameterName">> {
86
- }
87
- /**
88
- * An S3 bucket for use as an origin for a static site.
89
- * The bucket name will be stored in an SSM Parameter.
90
- * Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.
91
- */
92
- export declare class GuS3OriginBucket extends GuS3Bucket implements IConstruct {
93
- /**
94
- * The name of the created SSM Parameter.
95
- */
96
- readonly parameterName: string;
97
- readonly app: string;
98
- /**
99
- * For internal use only, used to generate a `riff-raff.yaml` file.
100
- *
101
- * @see [[RiffRaffYamlFileExperimental]]
102
- * @internal
103
- */
104
- readonly _deploymentProps: Required<GuS3OriginBucketDeploymentProps>;
105
- constructor(scope: GuStack, id: string, props: GuS3OriginBucketProps);
106
- }
107
17
  export {};
108
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAqB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,WAAW;CAAG;;;;;;AAE3F;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAA2B;gBAC7C,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe;CAQ/D;AAED,UAAU,+BAA+B;IACvC;;;;;;;;OAQG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;;;;;;OAQG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEvC;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE3C;;;;;;;;;;;;;;OAcG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,qBACf,SAAQ,eAAe,EACrB,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,mBAAmB,CAAC,CAAC;CAAG;AAE1E;;;;GAIG;AAEH,qBAAa,gBAAiB,SAAQ,UAAW,YAAW,UAAU;IACpE;;OAEG;IACH,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,SAAgB,GAAG,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,SAAgB,gBAAgB,EAAE,QAAQ,CAAC,+BAA+B,CAAC,CAAC;gBAEhE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;CA4BrE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAqB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,WAAW;CAAG;;;;;;AAE3F;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAA2B;gBAC7C,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe;CAQ/D"}
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuS3OriginBucket = exports.GuS3Bucket = void 0;
3
+ exports.GuS3Bucket = void 0;
4
4
  const aws_cdk_lib_1 = require("aws-cdk-lib");
5
5
  const aws_s3_1 = require("aws-cdk-lib/aws-s3");
6
- const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
7
6
  const app_aware_construct_1 = require("../../utils/mixin/app-aware-construct");
8
7
  /**
9
8
  * A construct to create a bucket with a "retain" policy to prevent it from being deleted. It will be orphaned instead.
@@ -19,35 +18,4 @@ class GuS3Bucket extends (0, app_aware_construct_1.GuAppAwareConstruct)(aws_s3_1
19
18
  }
20
19
  }
21
20
  exports.GuS3Bucket = GuS3Bucket;
22
- /**
23
- * An S3 bucket for use as an origin for a static site.
24
- * The bucket name will be stored in an SSM Parameter.
25
- * Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.
26
- */
27
- // implementing `IConstruct` is a no-op here as `Bucket` ultimately does so already. We explicitly do so to avoid a `SuspiciousTypeOfGuard` warning in `riff-raff-yaml-file/index.ts`.
28
- class GuS3OriginBucket extends GuS3Bucket {
29
- constructor(scope, id, props) {
30
- const { stage, stack } = scope;
31
- const { app, withoutStageAwareness = false, cacheControl = {}, surrogateControl = {}, mimeTypes = {} } = props;
32
- super(scope, id, props);
33
- this.app = app;
34
- const stageAgnosticParameterParts = [stack, app, `${app}-origin-bucket`];
35
- const parameterParts = withoutStageAwareness
36
- ? stageAgnosticParameterParts
37
- : [stage, ...stageAgnosticParameterParts];
38
- this.parameterName = `/${parameterParts.join("/")}`;
39
- new aws_ssm_1.StringParameter(scope, `${id}-ssm-param`, {
40
- parameterName: this.parameterName,
41
- stringValue: this.bucketName,
42
- });
43
- this._deploymentProps = {
44
- withoutStageAwareness,
45
- cacheControl,
46
- surrogateControl,
47
- mimeTypes,
48
- baseParameterName: `/${stageAgnosticParameterParts.join("/")}`,
49
- };
50
- }
51
- }
52
- exports.GuS3OriginBucket = GuS3OriginBucket;
53
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../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AC,aAAa;YACjC,WAAW,EAAE,IAAI,CAAC,UAAU;SAC7B,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,GAAG;YACtB,qBAAqB;YACrB,YAAY;YACZ,gBAAgB;YAChB,SAAS;YACT,iBAAiB,EAAE,IAAI,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;SAC/D,CAAC;IACJ,CAAC;CACF;AA5CD,4CA4CC","sourcesContent":["import type { Duration } from \"aws-cdk-lib\";\nimport { RemovalPolicy } from \"aws-cdk-lib\";\nimport type { BucketProps } from \"aws-cdk-lib/aws-s3\";\nimport { BlockPublicAccess, Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport type { IConstruct } from \"constructs\";\nimport { GuAppAwareConstruct } from \"../../utils/mixin/app-aware-construct\";\nimport type { AppIdentity, GuStack } from \"../core\";\n\nexport interface GuS3BucketProps extends Omit<BucketProps, \"removalPolicy\">, AppIdentity {}\n\n/**\n * A construct to create a bucket with a \"retain\" policy to prevent it from being deleted. It will be orphaned instead.\n */\nexport class GuS3Bucket extends GuAppAwareConstruct(Bucket) {\n constructor(scope: GuStack, id: string, props: GuS3BucketProps) {\n super(scope, id, {\n removalPolicy: RemovalPolicy.RETAIN,\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n ...props,\n });\n }\n}\n\ninterface GuS3OriginBucketDeploymentProps {\n /**\n * Customises the SSM Parameter path, making it stage agnostic.\n * Useful when a single bucket is used across multiple stages.\n *\n * When `false` the path will be `/<STAGE>/<STACK>/<APP>/<APP>-origin-bucket`.\n * When `true` the path will be `/<STACK>/<APP>/<APP>-origin-bucket`.\n *\n * @default false\n */\n withoutStageAwareness: boolean;\n\n /**\n * Used to configure `bucketSsmKeyStageParam` in a generated `riff-raff.yaml` file.\n *\n * The SSM Parameter path, without a stage prefix.\n *\n * Not settable by user.\n *\n * @internal\n */\n baseParameterName: string;\n\n /**\n * Used to configure `cacheControl` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * Set the cache control header for the uploaded files.\n *\n * The key is a regular expression to match uploaded files.\n * The value is the max-age to set in the `Cache-Control` header.\n *\n * @example\n * To cache all files for one hour:\n * ```ts\n * { \".*\", Duration.hours(1) }\n * ```\n *\n * @default cache nothing\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n cacheControl: Record<string, Duration>;\n\n /**\n * Used to configure `surrogateControl` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * Same as [[cacheControl]], but for setting the surrogate-control cache header, which is used by Fastly.\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n surrogateControl: Record<string, Duration>;\n\n /**\n * Used to configure `mimeTypes` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * A map of file extension to MIME type.\n *\n * When a file is uploaded with a file extension that is in this map, the Content-Type header will be set to the MIME type provided.\n *\n * @example\n * ```ts\n * { \"xpi\", \"application/x-xpinstall\" }\n * ```\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n mimeTypes: Record<string, string>;\n}\n\nexport interface GuS3OriginBucketProps\n extends GuS3BucketProps,\n Partial<Omit<GuS3OriginBucketDeploymentProps, \"baseParameterName\">> {}\n\n/**\n * An S3 bucket for use as an origin for a static site.\n * The bucket name will be stored in an SSM Parameter.\n * Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.\n */\n// implementing `IConstruct` is a no-op here as `Bucket` ultimately does so already. We explicitly do so to avoid a `SuspiciousTypeOfGuard` warning in `riff-raff-yaml-file/index.ts`.\nexport class GuS3OriginBucket extends GuS3Bucket implements IConstruct {\n /**\n * The name of the created SSM Parameter.\n */\n public readonly parameterName: string;\n\n public readonly app: string;\n\n /**\n * For internal use only, used to generate a `riff-raff.yaml` file.\n *\n * @see [[RiffRaffYamlFileExperimental]]\n * @internal\n */\n public readonly _deploymentProps: Required<GuS3OriginBucketDeploymentProps>;\n\n constructor(scope: GuStack, id: string, props: GuS3OriginBucketProps) {\n const { stage, stack } = scope;\n const { app, withoutStageAwareness = false, cacheControl = {}, surrogateControl = {}, mimeTypes = {} } = props;\n\n super(scope, id, props);\n\n this.app = app;\n\n const stageAgnosticParameterParts = [stack, app, `${app}-origin-bucket`];\n const parameterParts = withoutStageAwareness\n ? stageAgnosticParameterParts\n : [stage, ...stageAgnosticParameterParts];\n\n this.parameterName = `/${parameterParts.join(\"/\")}`;\n\n new StringParameter(scope, `${id}-ssm-param`, {\n parameterName: this.parameterName,\n stringValue: this.bucketName,\n });\n\n this._deploymentProps = {\n withoutStageAwareness,\n cacheControl,\n surrogateControl,\n mimeTypes,\n baseParameterName: `/${stageAgnosticParameterParts.join(\"/\")}`,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,+CAA+D;AAC/D,+EAA4E;AAK5E;;GAEG;AACH,MAAa,UAAW,SAAQ,IAAA,yCAAmB,EAAC,eAAM,CAAC;IACzD,YAAY,KAAc,EAAE,EAAU,EAAE,KAAsB;QAC5D,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE;YACf,aAAa,EAAE,2BAAa,CAAC,MAAM;YACnC,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,0BAAiB,CAAC,SAAS;YAC9C,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF;AATD,gCASC","sourcesContent":["import { RemovalPolicy } from \"aws-cdk-lib\";\nimport type { BucketProps } from \"aws-cdk-lib/aws-s3\";\nimport { BlockPublicAccess, Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { GuAppAwareConstruct } from \"../../utils/mixin/app-aware-construct\";\nimport type { AppIdentity, GuStack } from \"../core\";\n\nexport interface GuS3BucketProps extends Omit<BucketProps, \"removalPolicy\">, AppIdentity {}\n\n/**\n * A construct to create a bucket with a \"retain\" policy to prevent it from being deleted. It will be orphaned instead.\n */\nexport class GuS3Bucket extends GuAppAwareConstruct(Bucket) {\n constructor(scope: GuStack, id: string, props: GuS3BucketProps) {\n super(scope, id, {\n removalPolicy: RemovalPolicy.RETAIN,\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n ...props,\n });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { GuAutoScalingGroup } from "../../../constructs/autoscaling";
2
2
  import type { CdkStacksDifferingOnlyByStage, RiffRaffDeployment, RiffRaffDeploymentProps } from "../types";
3
3
  export declare function cloudFormationDeployment(cdkStacks: CdkStacksDifferingOnlyByStage, dependencies: RiffRaffDeployment[], contentDirectory: string): RiffRaffDeployment;
4
- export declare function addAmiParametersToCloudFormationDeployment(cfnDeployment: RiffRaffDeployment, asg: GuAutoScalingGroup): RiffRaffDeploymentProps;
4
+ export declare function addAmiParametersToCloudFormationDeployment(cfnDeployment: RiffRaffDeployment, autoScalingGroups: GuAutoScalingGroup[]): RiffRaffDeploymentProps;
5
5
  //# sourceMappingURL=cloudformation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudformation.d.ts","sourceRoot":"","sources":["../../../../src/experimental/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE3G,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,6BAA6B,EACxC,YAAY,EAAE,kBAAkB,EAAE,EAClC,gBAAgB,EAAE,MAAM,GACvB,kBAAkB,CAwCpB;AAED,wBAAgB,0CAA0C,CACxD,aAAa,EAAE,kBAAkB,EACjC,GAAG,EAAE,kBAAkB,GACtB,uBAAuB,CAmBzB"}
1
+ {"version":3,"file":"cloudformation.d.ts","sourceRoot":"","sources":["../../../../src/experimental/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE3G,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,6BAA6B,EACxC,YAAY,EAAE,kBAAkB,EAAE,EAClC,gBAAgB,EAAE,MAAM,GACvB,kBAAkB,CAwCpB;AAED,wBAAgB,0CAA0C,CACxD,aAAa,EAAE,kBAAkB,EACjC,iBAAiB,EAAE,kBAAkB,EAAE,GACtC,uBAAuB,CA8BzB"}
@@ -32,21 +32,29 @@ function cloudFormationDeployment(cdkStacks, dependencies, contentDirectory) {
32
32
  };
33
33
  }
34
34
  exports.cloudFormationDeployment = cloudFormationDeployment;
35
- function addAmiParametersToCloudFormationDeployment(cfnDeployment, asg) {
36
- const { imageRecipe, app, amiParameter } = asg;
37
- if (!imageRecipe) {
38
- throw new Error(`Unable to produce a working riff-raff.yaml file; imageRecipe missing from ASG ${app}`);
39
- }
35
+ function addAmiParametersToCloudFormationDeployment(cfnDeployment, autoScalingGroups) {
36
+ const amiParametersToTags = autoScalingGroups.reduce((acc, asg) => {
37
+ const { imageRecipe, app, amiParameter } = asg;
38
+ if (!imageRecipe) {
39
+ throw new Error(`Unable to produce a working riff-raff.yaml file; imageRecipe missing from ASG ${app}`);
40
+ }
41
+ const Recipe = typeof imageRecipe === "string" ? imageRecipe : imageRecipe.Recipe;
42
+ const AmigoStage = typeof imageRecipe === "string" ? "PROD" : imageRecipe.AmigoStage ?? "PROD";
43
+ return {
44
+ ...acc,
45
+ [amiParameter.node.id]: {
46
+ BuiltBy: "amigo",
47
+ AmigoStage,
48
+ Recipe,
49
+ },
50
+ };
51
+ }, {});
40
52
  return {
41
53
  ...cfnDeployment.props,
42
54
  parameters: {
43
55
  ...cfnDeployment.props.parameters,
44
- amiParameter: amiParameter.node.id,
45
- amiTags: {
46
- BuiltBy: "amigo",
47
- Recipe: imageRecipe,
48
- AmigoStage: "PROD",
49
- },
56
+ // only add the `amiParametersToTags` property if there are some
57
+ ...(autoScalingGroups.length > 0 && { amiParametersToTags }),
50
58
  },
51
59
  };
52
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cloudformation.js","sourceRoot":"","sources":["../../../../src/experimental/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":";;;AAGA,SAAgB,wBAAwB,CACtC,SAAwC,EACxC,YAAkC,EAClC,gBAAwB;IAExB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;KAC1F;IAED,qHAAqH;IACrH,8GAA8G;IAC9G,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAE,CAAC;IAC/B,MAAM,EACJ,MAAM,EACN,KAAK,EACL,WAAW,EAAE,EAAE,IAAI,EAAE,GACtB,GAAG,QAAQ,CAAC;IAEb,yFAAyF;IACzF,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAE9E,MAAM,kBAAkB,GAAG,SAAS,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;QACjC,GAAG,GAAG;QACN,CAAC,KAAK,CAAC,EAAE,YAAY;KACtB,CAAC,EACF,EAAE,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACtD,KAAK,EAAE;YACL,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB,GAAG,EAAE,cAAc;YACnB,gBAAgB;YAChB,UAAU,EAAE;gBACV,kBAAkB;aACnB;YACD,yDAAyD;YACzD,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;SACvF;KACF,CAAC;AACJ,CAAC;AA5CD,4DA4CC;AAED,SAAgB,0CAA0C,CACxD,aAAiC,EACjC,GAAuB;IAEvB,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC;IAE/C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iFAAiF,GAAG,EAAE,CAAC,CAAC;KACzG;IAED,OAAO;QACL,GAAG,aAAa,CAAC,KAAK;QACtB,UAAU,EAAE;YACV,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU;YACjC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE;YAClC,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,WAAW;gBACnB,UAAU,EAAE,MAAM;aACnB;SACF;KACF,CAAC;AACJ,CAAC;AAtBD,gGAsBC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../../constructs/autoscaling\";\nimport type { CdkStacksDifferingOnlyByStage, RiffRaffDeployment, RiffRaffDeploymentProps } from \"../types\";\n\nexport function cloudFormationDeployment(\n cdkStacks: CdkStacksDifferingOnlyByStage,\n dependencies: RiffRaffDeployment[],\n contentDirectory: string\n): RiffRaffDeployment {\n if (cdkStacks.length === 0) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n // The stacks in `cdkStacks` only differ by stage, so we can just use the first item in the list for key information.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- length of `cdkStacks` is checked above\n const cdkStack = cdkStacks[0]!;\n const {\n region,\n stack,\n constructor: { name },\n } = cdkStack;\n\n // TODO remove `lodash.kebabcase` dep as it's not that much code to kebab-ise a string...\n const kebabClassName = name.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n\n const templateStagePaths = cdkStacks.reduce(\n (acc, { stage, templateFile }) => ({\n ...acc,\n [stage]: templateFile,\n }),\n {}\n );\n\n return {\n name: [\"cfn\", region, stack, kebabClassName].join(\"-\"),\n props: {\n type: \"cloud-formation\",\n regions: new Set([region]),\n stacks: new Set([stack]),\n app: kebabClassName,\n contentDirectory,\n parameters: {\n templateStagePaths,\n },\n // only add the `dependencies` property if there are some\n ...(dependencies.length > 0 && { dependencies: dependencies.map(({ name }) => name) }),\n },\n };\n}\n\nexport function addAmiParametersToCloudFormationDeployment(\n cfnDeployment: RiffRaffDeployment,\n asg: GuAutoScalingGroup\n): RiffRaffDeploymentProps {\n const { imageRecipe, app, amiParameter } = asg;\n\n if (!imageRecipe) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; imageRecipe missing from ASG ${app}`);\n }\n\n return {\n ...cfnDeployment.props,\n parameters: {\n ...cfnDeployment.props.parameters,\n amiParameter: amiParameter.node.id,\n amiTags: {\n BuiltBy: \"amigo\",\n Recipe: imageRecipe,\n AmigoStage: \"PROD\",\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"cloudformation.js","sourceRoot":"","sources":["../../../../src/experimental/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":";;;AAGA,SAAgB,wBAAwB,CACtC,SAAwC,EACxC,YAAkC,EAClC,gBAAwB;IAExB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;KAC1F;IAED,qHAAqH;IACrH,8GAA8G;IAC9G,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAE,CAAC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EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,iFAAiF,GAAG,EAAE,CAAC,CAAC;SACzG;QAED,MAAM,MAAM,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;QAClF,MAAM,UAAU,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,IAAI,MAAM,CAAC;QAE/F,OAAO;YACL,GAAG,GAAG;YACN,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;gBACtB,OAAO,EAAE,OAAO;gBAChB,UAAU;gBACV,MAAM;aACP;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,GAAG,aAAa,CAAC,KAAK;QACtB,UAAU,EAAE;YACV,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU;YAEjC,gEAAgE;YAChE,GAAG,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC;SAC7D;KACF,CAAC;AACJ,CAAC;AAjCD,gGAiCC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../../constructs/autoscaling\";\nimport type { CdkStacksDifferingOnlyByStage, RiffRaffDeployment, RiffRaffDeploymentProps } from \"../types\";\n\nexport function cloudFormationDeployment(\n cdkStacks: CdkStacksDifferingOnlyByStage,\n dependencies: RiffRaffDeployment[],\n contentDirectory: string\n): RiffRaffDeployment {\n if (cdkStacks.length === 0) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n // The stacks in `cdkStacks` only differ by stage, so we can just use the first item in the list for key information.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- length of `cdkStacks` is checked above\n const cdkStack = cdkStacks[0]!;\n const {\n region,\n stack,\n constructor: { name },\n } = cdkStack;\n\n // TODO remove `lodash.kebabcase` dep as it's not that much code to kebab-ise a string...\n const kebabClassName = name.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n\n const templateStagePaths = cdkStacks.reduce(\n (acc, { stage, templateFile }) => ({\n ...acc,\n [stage]: templateFile,\n }),\n {}\n );\n\n return {\n name: [\"cfn\", region, stack, kebabClassName].join(\"-\"),\n props: {\n type: \"cloud-formation\",\n regions: new Set([region]),\n stacks: new Set([stack]),\n app: kebabClassName,\n contentDirectory,\n parameters: {\n templateStagePaths,\n },\n // only add the `dependencies` property if there are some\n ...(dependencies.length > 0 && { dependencies: dependencies.map(({ name }) => name) }),\n },\n };\n}\n\nexport function addAmiParametersToCloudFormationDeployment(\n cfnDeployment: RiffRaffDeployment,\n autoScalingGroups: GuAutoScalingGroup[]\n): RiffRaffDeploymentProps {\n const amiParametersToTags = autoScalingGroups.reduce((acc, asg) => {\n const { imageRecipe, app, amiParameter } = asg;\n\n if (!imageRecipe) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; imageRecipe missing from ASG ${app}`);\n }\n\n const Recipe = typeof imageRecipe === \"string\" ? imageRecipe : imageRecipe.Recipe;\n const AmigoStage = typeof imageRecipe === \"string\" ? \"PROD\" : imageRecipe.AmigoStage ?? \"PROD\";\n\n return {\n ...acc,\n [amiParameter.node.id]: {\n BuiltBy: \"amigo\",\n AmigoStage,\n Recipe,\n },\n };\n }, {});\n\n return {\n ...cfnDeployment.props,\n parameters: {\n ...cfnDeployment.props.parameters,\n\n // only add the `amiParametersToTags` property if there are some\n ...(autoScalingGroups.length > 0 && { amiParametersToTags }),\n },\n };\n}\n"]}
@@ -9,7 +9,6 @@ import type { App } from "aws-cdk-lib";
9
9
  * - Multiple regions
10
10
  * - Lambda applications
11
11
  * - EC2 (autoscaling) applications
12
- * - Upload of static files to S3
13
12
  *
14
13
  * For lambda applications, 3 deployments will be defined:
15
14
  * 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)
@@ -18,13 +17,9 @@ import type { App } from "aws-cdk-lib";
18
17
  *
19
18
  * For EC2 applications, 3 deployments will be defined:
20
19
  * 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)
21
- * 2. CloudFormation deploy (`cloud-formation`)
20
+ * 2. CloudFormation deploy (`cloud-formation`)
22
21
  * 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)
23
22
  *
24
- * For S3 uploads, 2 deployments will be defined:
25
- * 1. Artifact upload (`aws-s3`, `action: [uploadStaticFiles]`)
26
- * 2. CloudFormation deploy (`cloud-formation`)
27
- *
28
23
  * It assumes a Riff-Raff bundle structure as follows:
29
24
  *
30
25
  * ```
@@ -33,12 +28,8 @@ import type { App } from "aws-cdk-lib";
33
28
  * │ └── MyApplication.template.json
34
29
  * ├── my-application
35
30
  * │ └── my-application.deb
36
- * ├── my-lambda
37
- * │ └── my-lambda.zip
38
- * └── my-static-site
39
- * ├── index.html
40
- * ├── main.js
41
- * └── index.css
31
+ * └── my-lambda
32
+ * └── my-lambda.zip
42
33
  * ```
43
34
  *
44
35
  * That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.
@@ -61,7 +52,7 @@ export declare class RiffRaffYamlFileExperimental {
61
52
  private isCdkStackPresent;
62
53
  /**
63
54
  * Check there are the appropriate number of `GuStack`s.
64
- * Expect to find an instance for each combination of `GuStack`, `stack`, `region`, and `stage`.
55
+ * Expect to find an instance for each combination of `stack`, and `stage`.
65
56
  *
66
57
  * If not valid, a message is logged describing what is missing to aid debugging.
67
58
  *
@@ -103,14 +94,12 @@ export declare class RiffRaffYamlFileExperimental {
103
94
  * ```log
104
95
  * Unable to produce a working riff-raff.yaml file; missing 1 definitions (details below)
105
96
  *
106
- * For the class: MyApplicationStack
107
- *
108
- * ┌───────────────┬────────────────────────────┐
109
- * │ (index) │ eu-west-1 │
110
- * ├───────────────┼────────────────────────────┤
111
- * │ deploy │ { CODE: '✅', PROD: '✅' } │
112
- * │ media-service │ { CODE: '❌', PROD: '✅' } │
113
- * └───────────────┴────────────────────────────┘
97
+ * ┌───────────────┬──────┬──────┐
98
+ * │ (index) │ CODE │ PROD │
99
+ * ├───────────────┼──────┼──────┤
100
+ * │ deploy │ '✅' │ '✅' │
101
+ * │ media-service │ '❌' │ '✅' │
102
+ * └───────────────┴──────┴──────┘
114
103
  * ```
115
104
  *
116
105
  * @private
@@ -119,7 +108,6 @@ export declare class RiffRaffYamlFileExperimental {
119
108
  private validateAllRegionsAreResolved;
120
109
  private getLambdas;
121
110
  private getAutoScalingGroups;
122
- private getOriginBuckets;
123
111
  constructor(app: App);
124
112
  /**
125
113
  * The `riff-raff.yaml` file as a string.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAyBvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IAEtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,iBAAiB;IAqBzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;IACH,OAAO,CAAC,mBAAmB;IAkD3B,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,gBAAgB;gBAMZ,GAAG,EAAE,GAAG;IAoEpB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAiBhB;;;OAGG;IACH,KAAK,IAAI,IAAI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