@guardian/cdk 63.6.2 → 64.1.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 (110) hide show
  1. package/lib/aspects/cfn-include-reporter.js.map +1 -1
  2. package/lib/aspects/cfn-parameter-reporter.js.map +1 -1
  3. package/lib/aspects/metadata.js.map +1 -1
  4. package/lib/bin/aws-credential-provider.d.ts.map +1 -1
  5. package/lib/bin/commands/account-readiness/index.d.ts.map +1 -1
  6. package/lib/bin/commands/account-readiness/index.js.map +1 -1
  7. package/lib/bin/commands/account-readiness/ssm.d.ts.map +1 -1
  8. package/lib/bin/commands/account-readiness/ssm.js.map +1 -1
  9. package/lib/bin/commands/aws-cdk-version.d.ts.map +1 -1
  10. package/lib/bin/commands/new-project/index.d.ts.map +1 -1
  11. package/lib/bin/commands/new-project/index.js.map +1 -1
  12. package/lib/bin/commands/new-project/utils/app.d.ts.map +1 -1
  13. package/lib/bin/commands/new-project/utils/app.js.map +1 -1
  14. package/lib/bin/commands/new-project/utils/imports.js.map +1 -1
  15. package/lib/bin/commands/new-project/utils/init.d.ts.map +1 -1
  16. package/lib/bin/commands/new-project/utils/init.js.map +1 -1
  17. package/lib/bin/commands/new-project/utils/snapshot.d.ts.map +1 -1
  18. package/lib/bin/commands/new-project/utils/snapshot.js.map +1 -1
  19. package/lib/bin/commands/new-project/utils/stack.d.ts.map +1 -1
  20. package/lib/bin/commands/new-project/utils/stack.js.map +1 -1
  21. package/lib/bin/commands/new-project/utils/utils.js +1 -2
  22. package/lib/bin/commands/new-project/utils/utils.js.map +1 -1
  23. package/lib/bin/index.js.map +1 -1
  24. package/lib/constants/library-info.js +3 -3
  25. package/lib/constants/library-info.js.map +1 -1
  26. package/lib/constructs/autoscaling/asg.js.map +1 -1
  27. package/lib/constructs/autoscaling/user-data.js.map +1 -1
  28. package/lib/constructs/cloudwatch/alarm.js.map +1 -1
  29. package/lib/constructs/core/identity.d.ts.map +1 -1
  30. package/lib/constructs/core/parameters/anghammarad.js.map +1 -1
  31. package/lib/constructs/core/parameters/fastly.js.map +1 -1
  32. package/lib/constructs/core/parameters/log-shipping.js.map +1 -1
  33. package/lib/constructs/core/parameters/s3.js.map +1 -1
  34. package/lib/constructs/core/parameters/vpc.js.map +1 -1
  35. package/lib/constructs/core/stack.js.map +1 -1
  36. package/lib/constructs/dns/dns-records.js.map +1 -1
  37. package/lib/constructs/ec2/security-groups/base.js.map +1 -1
  38. package/lib/constructs/ec2/vpc.d.ts.map +1 -1
  39. package/lib/constructs/ec2/vpc.js.map +1 -1
  40. package/lib/constructs/ecs/ecs-task.js +1 -1
  41. package/lib/constructs/ecs/ecs-task.js.map +1 -1
  42. package/lib/constructs/iam/policies/anghammarad.js.map +1 -1
  43. package/lib/constructs/iam/policies/describe-ec2.js.map +1 -1
  44. package/lib/constructs/iam/policies/kcl.js +1 -1
  45. package/lib/constructs/iam/policies/kcl.js.map +1 -1
  46. package/lib/constructs/iam/policies/log-shipping.js.map +1 -1
  47. package/lib/constructs/iam/policies/parameter-store-read.d.ts +8 -1
  48. package/lib/constructs/iam/policies/parameter-store-read.d.ts.map +1 -1
  49. package/lib/constructs/iam/policies/parameter-store-read.js +21 -0
  50. package/lib/constructs/iam/policies/parameter-store-read.js.map +1 -1
  51. package/lib/constructs/iam/policies/ssm-ssh.js.map +1 -1
  52. package/lib/constructs/iam/roles/instance-role.js +1 -1
  53. package/lib/constructs/iam/roles/instance-role.js.map +1 -1
  54. package/lib/constructs/lambda/lambda.js.map +1 -1
  55. package/lib/constructs/loadbalancing/alb/application-load-balancer.js.map +1 -1
  56. package/lib/constructs/loadbalancing/alb/application-target-group.js +1 -1
  57. package/lib/constructs/loadbalancing/alb/application-target-group.js.map +1 -1
  58. package/lib/constructs/ses/index.js.map +1 -1
  59. package/lib/constructs/vpc/vpc.js.map +1 -1
  60. package/lib/experimental/constructs/iam/policies/developer-policy.js.map +1 -1
  61. package/lib/experimental/constructs/riff-raff-deployment-id.js.map +1 -1
  62. package/lib/experimental/patterns/ec2-app.js.map +1 -1
  63. package/lib/experimental/patterns/gu-load-balanced-app.d.ts +5 -5
  64. package/lib/experimental/patterns/gu-load-balanced-app.d.ts.map +1 -1
  65. package/lib/experimental/patterns/gu-load-balanced-app.js +37 -28
  66. package/lib/experimental/patterns/gu-load-balanced-app.js.map +1 -1
  67. package/lib/patterns/api-lambda.js.map +1 -1
  68. package/lib/patterns/api-multiple-lambdas.js.map +1 -1
  69. package/lib/patterns/ec2-app/base.d.ts +3 -3
  70. package/lib/patterns/ec2-app/base.d.ts.map +1 -1
  71. package/lib/patterns/ec2-app/base.js +4 -11
  72. package/lib/patterns/ec2-app/base.js.map +1 -1
  73. package/lib/riff-raff-yaml-file/deployments/autoscaling.js +2 -3
  74. package/lib/riff-raff-yaml-file/deployments/autoscaling.js.map +1 -1
  75. package/lib/riff-raff-yaml-file/deployments/cloudformation.js +3 -4
  76. package/lib/riff-raff-yaml-file/deployments/cloudformation.js.map +1 -1
  77. package/lib/riff-raff-yaml-file/deployments/lambda.js +2 -3
  78. package/lib/riff-raff-yaml-file/deployments/lambda.js.map +1 -1
  79. package/lib/riff-raff-yaml-file/deployments/update-parameters.js +1 -2
  80. package/lib/riff-raff-yaml-file/deployments/update-parameters.js.map +1 -1
  81. package/lib/riff-raff-yaml-file/group-by.js +5 -6
  82. package/lib/riff-raff-yaml-file/group-by.js.map +1 -1
  83. package/lib/riff-raff-yaml-file/index.js +2 -2
  84. package/lib/riff-raff-yaml-file/index.js.map +1 -1
  85. package/lib/types/access.js.map +1 -1
  86. package/lib/utils/array.js +1 -2
  87. package/lib/utils/array.js.map +1 -1
  88. package/lib/utils/cli/vpc.d.ts.map +1 -1
  89. package/lib/utils/cli/vpc.js.map +1 -1
  90. package/lib/utils/cognito/cognito.d.ts.map +1 -1
  91. package/lib/utils/exec.js +2 -3
  92. package/lib/utils/exec.js.map +1 -1
  93. package/lib/utils/git.js +2 -3
  94. package/lib/utils/git.js.map +1 -1
  95. package/lib/utils/lambda/event-source.js +2 -2
  96. package/lib/utils/lambda/event-source.js.map +1 -1
  97. package/lib/utils/math.d.ts.map +1 -1
  98. package/lib/utils/mixin/app-aware-construct.js +1 -2
  99. package/lib/utils/mixin/app-aware-construct.js.map +1 -1
  100. package/lib/utils/security-groups/helpers.d.ts.map +1 -1
  101. package/lib/utils/singleton.d.ts +1 -1
  102. package/lib/utils/singleton.d.ts.map +1 -1
  103. package/lib/utils/string.d.ts.map +1 -1
  104. package/lib/utils/test/assertions.js.map +1 -1
  105. package/lib/utils/test/attach-policy-to-test-role.d.ts.map +1 -1
  106. package/lib/utils/test/simple-gu-stack.js +1 -2
  107. package/lib/utils/test/simple-gu-stack.js.map +1 -1
  108. package/lib/utils/test/template.js +1 -2
  109. package/lib/utils/test/template.js.map +1 -1
  110. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/patterns/ec2-app/base.ts"],"names":[],"mappings":";;;AAAA,uGAAuG;AACvG,6CAA0D;AAE1D,iEAAsF;AACtF,yDAKiC;AAEjC,iDAAqD;AAErD,uFAA6F;AAC7F,uGAA2F;AAC3F,iDAA8D;AAC9D,uDAA+D;AAC/D,iDAAsD;AACtD,2CAAuC;AACvC,+CAAuF;AACvF,8CAAqD;AAErD,8DAA8E;AAE9E,4DAIqC;AAErC,gDAAkF;AAClF,8CAAsG;AAEtG,8CAAgF;AAChF,oDAA2D;AAC3D,kEAIwC;AAExC,uCAAwC;AAGxC,yDAAsE;AA2StE;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAe;IAClD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK;QACL,IAAI,EAAE,cAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACnB,WAAW,EAAE,iCAAiC,KAAK,CAAC,QAAQ,EAAE;KAC/D,CAAC,CAAC,CAAC;AACN,CAAC;AAND,oDAMC;AAED;;;;;;G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pC,QAAQ,EAAE,QAAQ;oBAClB,cAAc,EAAE,cAAc;oBAC9B,cAAc,EAAE,cAAc;oBAC9B,IAAI,EAAE,2CAAc,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;oBAC3C,cAAc,EAAE,sBAAQ,CAAC,OAAO,CAAC,uBAAuB,CAAC;iBAC1D,CAAC;aACH,CAAC,CAAC;YAEH,qEAAqE;YACrE,MAAM,sBAAsB,GAAG,IAAI,gCAA0B,CAAC,KAAK,EAAE,YAAY,EAAE;gBACjF,GAAG;gBACH,GAAG;aACJ,CAAC,CAAC;YAEH,YAAY,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;SACvD;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AA7UD,4BA6UC","sourcesContent":["/* eslint \"@guardian/tsdoc-required/tsdoc-required\": 2 -- to begin rolling this out for public APIs. */\nimport { Duration, SecretValue, Tags } from \"aws-cdk-lib\";\nimport type { BlockDevice, UpdatePolicy } from \"aws-cdk-lib/aws-autoscaling\";\nimport { AdditionalHealthCheckType, HealthChecks } from \"aws-cdk-lib/aws-autoscaling\";\nimport {\n ProviderAttribute,\n UserPool,\n UserPoolClientIdentityProvider,\n UserPoolIdentityProviderGoogle,\n} from \"aws-cdk-lib/aws-cognito\";\nimport type { InstanceType, IPeer, ISubnet, IVpc } from \"aws-cdk-lib/aws-ec2\";\nimport { Port, UserData } from \"aws-cdk-lib/aws-ec2\";\nimport type { HealthCheck as ALBHealthCheck } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport { ApplicationProtocol, ListenerAction } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport { AuthenticateCognitoAction } from \"aws-cdk-lib/aws-elasticloadbalancingv2-actions\";\nimport { Effect, PolicyStatement } from \"aws-cdk-lib/aws-iam\";\nimport { Architecture, Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport { AccessScope, MetadataKeys, NAMED_SSM_PARAMETER_PATHS } from \"../../constants\";\nimport { GuCertificate } from \"../../constructs/acm\";\nimport type { GuUserDataProps } from \"../../constructs/autoscaling\";\nimport { GuAutoScalingGroup, GuUserData } from \"../../constructs/autoscaling\";\nimport type { Http4xxAlarmProps, Http5xxAlarmProps, NoMonitoring } from \"../../constructs/cloudwatch\";\nimport {\n GuAlb4xxPercentageAlarm,\n GuAlb5xxPercentageAlarm,\n GuUnhealthyInstancesAlarm,\n} from \"../../constructs/cloudwatch\";\nimport type { GuStack } from \"../../constructs/core\";\nimport { AppIdentity, GuLoggingStreamNameParameter } from \"../../constructs/core\";\nimport { GuHttpsEgressSecurityGroup, GuSecurityGroup, GuVpc, SubnetType } from \"../../constructs/ec2\";\nimport type { GuInstanceRoleProps } from \"../../constructs/iam\";\nimport { GuGetPrivateConfigPolicy, GuInstanceRole } from \"../../constructs/iam\";\nimport { GuLambdaFunction } from \"../../constructs/lambda\";\nimport {\n GuApplicationLoadBalancer,\n GuApplicationTargetGroup,\n GuHttpsApplicationListener,\n} from \"../../constructs/loadbalancing\";\nimport type { WafProps } from \"../../constructs/loadbalancing\";\nimport { AppAccess } from \"../../types\";\nimport type { GuAsgCapacity, GuDomainName } from \"../../types\";\nimport type { AmigoProps } from \"../../types/amigo\";\nimport { getUserPoolDomainPrefix } from \"../../utils/cognito/cognito\";\n\n/**\n * To ship your application logs to ELK automatically, you must:\n *\n * 1. Set the `enabled` flag to true\n * 2. Include the `cdk-base` Amigo role in your AMI\n * 3. Log to `journald`. We recommend doing this by logging to `stdout` and\n * using `systemd` to start your app\n * 4. Confirm that your [[`systemdUnitName`]] is configured properly.\n *\n * Unless you have explicitly opted-out, appropriate IAM permissions for logging\n * to Kinesis will be configured automatically via the [[`GuEc2App`]] pattern.\n */\nexport interface ApplicationLoggingProps {\n /**\n * Enables forwarding of application logs to the Guardian ELK stack.\n *\n * Note, to work, you will need to also do the following non-CDK things:\n *\n * 1. Include the `cdk-base` Amigo role in your AMI.\n * 2. Log to `journald`. We recommend doing this by logging to `stdout` and\n * using `systemd` to start your app\n * 3. Confirm that your [[`systemdUnitName`]] is configured properly.\n *\n * Unless you have explicitly opted-out, appropriate IAM permissions for\n * logging to Kinesis will be configured automatically via the [[`GuEc2App`]]\n * pattern.\n *\n * @see https://github.com/guardian/amigo/tree/main/roles/cdk-base\n */\n enabled: boolean;\n /**\n * This needs to match the name of your SystemD unit.\n *\n * If your systemd unit is not `<app>.service` set this value.\n *\n * @defaultValue `<app>.service`\n */\n systemdUnitName?: string;\n}\n\n/**\n * @privateRemarks we should rename this to AlarmsProps.\n */\nexport interface Alarms {\n /**\n * Name of the target (SNS Topic) for alarm notifications.\n */\n snsTopicName: string;\n /**\n * Enable the 5xx alarm with settings.\n */\n http5xxAlarm: false | Http5xxAlarmProps;\n /**\n * Enable the 4xx alarm with settings.\n */\n http4xxAlarm?: false | Http4xxAlarmProps;\n /**\n * Enable the unhealthy instances alarm.\n */\n unhealthyInstancesAlarm: boolean;\n /**\n * Internal flag - users of this library should ignore this setting.\n */\n noMonitoring?: false;\n}\n\nexport interface GuEc2AppProps extends AppIdentity {\n /**\n * User data for the autoscaling group.\n */\n userData: GuUserDataProps | UserData;\n /**\n * Network access restrictions for your load balancer.\n *\n * Note, this merely provides defence in depth; you should NOT rely on network access restrictions alone for\n * restricting access. Use Google Auth for human access, or a suitable machine auth mechanism.\n */\n access: AppAccess;\n /**\n * The port your application runs on.\n */\n applicationPort: number;\n /**\n * Configure IAM roles for autoscaling group EC2 instances.\n */\n roleConfiguration?: GuInstanceRoleProps;\n /**\n * Enable and configure alarms.\n */\n monitoringConfiguration: Alarms | NoMonitoring;\n /**\n * EC2 instance type. Note, ensure your code is built for the same\n * architecture family (arm64 - 'Graviton' instances - or x64).\n */\n instanceType: InstanceType;\n /**\n * Enable and configures application logs.\n */\n applicationLogging?: ApplicationLoggingProps;\n\n /**\n * Enable access logging for this load balancer.\n * Access logs are written to an S3 bucket within your AWS account.\n * The bucket is created by {@link https://github.com/guardian/aws-account-setup}.\n * The logs are queryable via the `gucdk_access_logs` Athena database.\n *\n * @defaultValue true\n */\n withAccessLogging?: boolean;\n\n /**\n * Add block devices (additional storage).\n */\n blockDevices?: BlockDevice[];\n /**\n * Autoscaling group min and max sizes.\n */\n scaling: GuAsgCapacity;\n /**\n * Specify certificate for the load balancer.\n */\n certificateProps?: GuDomainName;\n\n /**\n * Configure AMIgo image recipe. This is only necessary if you are using GuCDK to generate your riff-raff.yaml file.\n */\n imageRecipe?: string | AmigoProps;\n /**\n * Specify the VPC to use.\n *\n * @see https://github.com/guardian/aws-account-setup\n */\n vpc?: IVpc;\n /**\n * Specify private subnets if using a non-default VPC or (generally\n * discouraged) to limit to a subset of the available subnets.\n */\n privateSubnets?: ISubnet[];\n\n /**\n * Specify private subnets if using a non-default VPC or (generally\n * discouraged) to limit to a subset of the available subnets.\n */\n publicSubnets?: ISubnet[];\n\n /**\n * Configure Google Auth.\n */\n googleAuth?: {\n /**\n * Enables Google Auth (via Cognito). **Additional MANUAL steps required -\n * see below.**\n *\n * Limits access to members of the allowed Google groups.\n *\n * Note, this does not currently support simultaneous machine access, so\n * only set to true if you only require staff access to your service, or are\n * supporting machine access in some other way.\n *\n * MANUAL STEPS: to get this to work, we need a Google Project and\n * associated credentials. Full instructions can be found here:\n *\n * https://docs.google.com/document/d/1_k1FSE52AZHXufWLTiKTI3xy5cGpziyHazSHTKrYfco/edit?usp=sharing\n *\n * DevX hope to automate this process in the near future.\n */\n enabled: true;\n /**\n * The domain users will access your service.\n *\n * Set this to the same as for certificateProps.\n */\n domain: string;\n /**\n * Groups used for membership checks.\n *\n * If specified, cannot be empty. Users must be a member of at least one\n * group to gain access.\n *\n * WARNING: groups must be specified with the `guardian.co.uk` domain, even\n * if that is the non-idiomatic choice for daily use.\n *\n * @defaultValue [`engineering@guardian.co.uk`]\n */\n allowedGroups?: string[];\n /**\n * The number of minutes before the session expires.\n *\n * Set this value to a safe period of time that revoked users\n * sessions will continue to function.\n *\n * NOTE: This value cannot be larger than 60 minutes.\n *\n * @defaultValue 15\n */\n sessionTimeoutInMinutes?: number;\n /**\n * Secrets Manager path containing Google OAuth2 Client credentials.\n *\n * NOTE: you do not need to set this value, but you DO need to generate and\n * store the associated credentials in Secrets Manager.\n *\n * Credentials should be stored in Secrets Manager as JSON:\n *\n * ```json\n * {\n * \"clientId\": \"my-client-id\",\n * \"clientSecret\": \"my-client-secret\"\n * }\n * ```\n *\n * @see `googleAuth.enabled` for how to generate.\n *\n * @defaultValue /:STAGE/:stack/:app/google-auth-credentials\n */\n credentialsSecretsManagerPath?: string;\n\n /**\n * When using Auth in the ALB, which stage of cognito-lambda to use.\n *\n * For most applications this should always be PROD, even in the CODE environments.\n *\n * @defaultValue PROD\n */\n cognitoAuthStage?: string;\n };\n\n /**\n * Specify custom healthcheck\n */\n healthcheck?: ALBHealthCheck;\n\n /**\n * Set http put response hop limit for the launch template.\n * It can be necessary to raise this value from the default of 1\n * for example when sharing the instance profile with a docker container running on the instance.\n */\n instanceMetadataHopLimit?: number;\n\n /**\n * Specify an update policy for the ASG created by this pattern.\n *\n * @see https://docs.aws.amazon.com/cdk/api/latest/docs/aws-autoscaling-readme.html#update-policy\n *\n * @defaultValue UpdatePolicy.none() - Cloudformation does not attempt to rotate instances in the ASG\n * and must rely on riffraff to do so.\n */\n updatePolicy?: UpdatePolicy;\n\n /**\n * You can specify how long after an instance reaches the InService state it waits before contributing\n * usage data to the aggregated metrics. This specified time is called the default instance warmup.\n * This keeps dynamic scaling from being affected by metrics for individual instances that aren't yet\n * handling application traffic and that might be experiencing temporarily high usage of compute resources.\n *\n * @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-default-instance-warmup.html\n */\n defaultInstanceWarmup?: Duration;\n\n /**\n * You can specify if the arn of this load balancer should be exposed for protection via WAF\n *\n * If this value changes, it is only picked up on WAF configuration redeploy.\n *\n * NB this parameter setting _alone_ is not sufficient to protect the application.\n * You must also ensure that the application and stage combination is present in the WAF\n * configuration.\n *\n * See https://github.com/guardian/waf/tree/main/lib\n *\n * There is a \"gotcha\" when migrating to this functionality. You may not change only the Logical\n * ID of an SSM Parameter (see https://docs.aws.amazon.com/cdk/v2/guide/identifiers.html) and the\n * parameter name must be of the required form, meaning you cannot have an alternate name.\n *\n * You can either:\n *\n * Remove the old param and immediately redeploy with the new param (this does not affect\n * protection unless and until the WAF configuration is redeployed)\n *\n * OR\n *\n * Create an escape hatch by overriding the logical id (see \"ssm param escape hatch\" test for example)\n **/\n waf?: WafProps;\n\n /**\n * How often to send EC2 metrics, such as CPU usage.\n * By default, AWS will produce `5Minute` granular metrics.\n *\n * It is recommended to produce `1Minute` granular metrics in production,\n * especially when using ASG metrics to trigger horizontal scaling as it allows for earlier scaling.\n *\n * @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html\n */\n instanceMetricGranularity: \"1Minute\" | \"5Minute\";\n}\n\n/**\n * Use this to allow specific CIDR ranges to access a load balancer over HTTPS\n */\nexport function restrictedCidrRanges(ranges: IPeer[]) {\n return ranges.map((range) => ({\n range,\n port: Port.tcp(443),\n description: `Allow access on port 443 from ${range.uniqueId}`,\n }));\n}\n\n/**\n * Pattern which creates the resources needed to run an application on EC2\n * behind a load balancer. For convenience, you may wish to use [[`GuPlayApp`]]\n * or [[`GuNodeApp`]], which extend this class.\n *\n * See props for further details.\n */\nexport class GuEc2App extends Construct {\n /*\n * These are public for now, as this allows users to\n * modify these constructs as desired to fit their\n * specific needs.\n * In the future, we might build functionality to better enable users\n * to access in-pattern constructs, but this would allow teams to be unblocked\n * in the short term.\n * */\n public readonly vpc: IVpc;\n public readonly certificate?: GuCertificate;\n public readonly loadBalancer: GuApplicationLoadBalancer;\n public readonly autoScalingGroup: GuAutoScalingGroup;\n public readonly listener: GuHttpsApplicationListener;\n public readonly targetGroup: GuApplicationTargetGroup;\n\n constructor(scope: GuStack, props: GuEc2AppProps) {\n const {\n access,\n withAccessLogging = true,\n app,\n // We should update this default once a significant number of apps have migrated to devx-logs\n applicationLogging = { enabled: false },\n applicationPort,\n blockDevices,\n certificateProps,\n instanceType,\n monitoringConfiguration,\n roleConfiguration = { withoutLogShipping: false, additionalPolicies: [] },\n scaling: { minimumInstances, maximumInstances = minimumInstances * 2 },\n userData: userDataLike,\n imageRecipe,\n vpc = GuVpc.fromIdParameter(scope, AppIdentity.suffixText({ app }, \"VPC\")),\n privateSubnets = GuVpc.subnetsFromParameter(scope, { type: SubnetType.PRIVATE, app }),\n publicSubnets = GuVpc.subnetsFromParameter(scope, { type: SubnetType.PUBLIC, app }),\n instanceMetadataHopLimit,\n updatePolicy,\n defaultInstanceWarmup,\n instanceMetricGranularity,\n waf,\n } = props;\n\n super(scope, app); // The assumption is `app` is unique\n\n // We should really prevent users from doing this via the type system,\n // but that requires a breaking change to the API\n if (applicationLogging.enabled && roleConfiguration.withoutLogShipping) {\n throw new Error(\n \"Application logging has been enabled (via the `applicationLogging` prop) but your `roleConfiguration` sets \" +\n \"`withoutLogShipping` to true. Please turn off application logging or remove `withoutLogShipping`\",\n );\n }\n\n const userData = userDataLike instanceof UserData ? userDataLike : new GuUserData(scope, { ...userDataLike, app });\n\n AppAccess.validate(access);\n\n const certificate =\n typeof certificateProps !== \"undefined\"\n ? new GuCertificate(scope, {\n app,\n domainName: certificateProps.domainName,\n hostedZoneId: certificateProps.hostedZoneId,\n })\n : undefined;\n\n const maybePrivateConfigPolicy =\n userData instanceof GuUserData && userData.configuration\n ? [new GuGetPrivateConfigPolicy(scope, \"GetPrivateConfigFromS3Policy\", userData.configuration)]\n : [];\n\n const mergedRoleConfiguration: GuInstanceRoleProps = {\n withoutLogShipping: roleConfiguration.withoutLogShipping,\n additionalPolicies: maybePrivateConfigPolicy.concat(roleConfiguration.additionalPolicies ?? []),\n };\n\n const autoScalingGroup = new GuAutoScalingGroup(scope, \"AutoScalingGroup\", {\n app,\n vpc,\n instanceType,\n minimumInstances,\n maximumInstances,\n role: new GuInstanceRole(scope, { app, ...mergedRoleConfiguration }),\n\n // TODO should this be defaulted at pattern or construct level?\n healthChecks: HealthChecks.withAdditionalChecks({\n additionalTypes: [AdditionalHealthCheckType.ELB],\n gracePeriod: Duration.minutes(2),\n }),\n\n userData: userData instanceof GuUserData ? userData.userData : userData,\n vpcSubnets: { subnets: privateSubnets },\n ...(blockDevices && { blockDevices }),\n imageRecipe,\n httpPutResponseHopLimit: instanceMetadataHopLimit,\n updatePolicy,\n defaultInstanceWarmup,\n instanceMetricGranularity,\n });\n\n // This allows automatic shipping of instance Cloud Init logs when using the\n // `cdk-base` Amigo role on your AMI.\n Tags.of(autoScalingGroup).add(\n MetadataKeys.LOG_KINESIS_STREAM_NAME,\n GuLoggingStreamNameParameter.getInstance(scope).valueAsString,\n );\n\n if (applicationLogging.enabled) {\n // This allows automatic shipping of application logs when using the\n // `cdk-base` Amigo role on your AMI.\n Tags.of(autoScalingGroup).add(\n MetadataKeys.SYSTEMD_UNIT,\n applicationLogging.systemdUnitName ? `${applicationLogging.systemdUnitName}.service` : `${app}.service`,\n );\n }\n\n const loadBalancer = new GuApplicationLoadBalancer(scope, \"LoadBalancer\", {\n app,\n vpc,\n // Setting internetFacing to true does not necessarily allow public access to the load balancer itself. That is handled by the listener's `open` prop.\n internetFacing: access.scope !== AccessScope.INTERNAL,\n vpcSubnets: {\n subnets: access.scope === AccessScope.INTERNAL ? privateSubnets : publicSubnets,\n },\n withAccessLogging,\n waf,\n });\n\n const targetGroup = new GuApplicationTargetGroup(scope, \"TargetGroup\", {\n app,\n vpc,\n protocol: ApplicationProtocol.HTTP,\n targets: [autoScalingGroup],\n port: applicationPort,\n healthCheck: props.healthcheck,\n });\n\n const listener = new GuHttpsApplicationListener(scope, \"Listener\", {\n app,\n loadBalancer,\n certificate,\n targetGroup,\n // When open=true, AWS will create a security group which allows all inbound traffic over HTTPS\n open: access.scope === AccessScope.PUBLIC && typeof certificate !== \"undefined\",\n });\n\n // Since AWS won't create a security group automatically when open=false, we need to add our own\n if (access.scope !== AccessScope.PUBLIC) {\n loadBalancer.addSecurityGroup(\n new GuSecurityGroup(scope, `${access.scope}IngressSecurityGroup`, {\n app,\n vpc,\n description: \"Allow restricted ingress from CIDR ranges\",\n allowAllOutbound: false,\n ingresses: restrictedCidrRanges(access.cidrRanges),\n }),\n );\n }\n\n if (!monitoringConfiguration.noMonitoring) {\n const { http5xxAlarm, http4xxAlarm, snsTopicName, unhealthyInstancesAlarm } = monitoringConfiguration;\n\n if (http4xxAlarm) {\n new GuAlb4xxPercentageAlarm(scope, {\n app,\n loadBalancer,\n snsTopicName,\n ...http4xxAlarm,\n });\n }\n if (http5xxAlarm) {\n new GuAlb5xxPercentageAlarm(scope, {\n app,\n loadBalancer,\n snsTopicName,\n ...http5xxAlarm,\n });\n }\n if (unhealthyInstancesAlarm) {\n new GuUnhealthyInstancesAlarm(scope, {\n app,\n targetGroup,\n snsTopicName,\n });\n }\n }\n\n if (props.googleAuth?.enabled) {\n const prefix = `/${scope.stage}/${scope.stack}/${app}`;\n\n const {\n allowedGroups = [\"engineering@guardian.co.uk\"],\n sessionTimeoutInMinutes = 15,\n credentialsSecretsManagerPath = `${prefix}/google-auth-credentials`,\n } = props.googleAuth;\n\n if (sessionTimeoutInMinutes > 60) {\n throw new Error(\"googleAuth.sessionTimeoutInMinutes must be <= 60!\");\n }\n\n if (allowedGroups.length < 1) {\n throw new Error(\"googleAuth.allowedGroups cannot be empty!\");\n }\n\n if (allowedGroups.find((group) => !group.endsWith(\"@guardian.co.uk\"))) {\n throw new Error(\"googleAuth.allowedGroups must use the @guardian.co.uk domain.\");\n }\n\n const deployToolsAccountId = StringParameter.fromStringParameterName(\n scope,\n \"deploy-tools-account-id-parameter\",\n NAMED_SSM_PARAMETER_PATHS.DeployToolsAccountId.path,\n );\n\n const cognitoAuthStage = props.googleAuth.cognitoAuthStage ?? \"PROD\";\n\n // See https://github.com/guardian/cognito-auth-lambdas for the source\n // code here. ARN format is:\n // arn:aws:lambda:aws-region:acct-id:function:helloworld.\n const gatekeeperFunctionArn = `arn:aws:lambda:eu-west-1:${deployToolsAccountId.stringValue}:function:deploy-${cognitoAuthStage}-gatekeeper-lambda`;\n\n // Note, handler and filename must match here:\n // https://github.com/guardian/cognito-auth-lambdas.\n const authLambda = new GuLambdaFunction(scope, \"auth-lambda\", {\n app: app,\n memorySize: 128,\n handler: \"bootstrap\",\n runtime: Runtime.PROVIDED_AL2023,\n fileName: `deploy/${cognitoAuthStage}/cognito-lambda/devx-cognito-lambda-amd64-v2.zip`,\n withoutFilePrefix: true,\n withoutArtifactUpload: true,\n bucketNamePath: NAMED_SSM_PARAMETER_PATHS.OrganisationDistributionBucket.path,\n architecture: Architecture.X86_64,\n environment: {\n ALLOWED_GROUPS: allowedGroups.join(\",\"),\n GATEKEEPER_FUNCTION_ARN: gatekeeperFunctionArn,\n },\n });\n\n Tags.of(authLambda).add(\"Owner\", \"DevX\");\n\n authLambda.addToRolePolicy(\n new PolicyStatement({\n effect: Effect.ALLOW,\n actions: [\"lambda:InvokeFunction\"],\n resources: [gatekeeperFunctionArn],\n }),\n );\n\n // Cognito user pool. We require both lambdas: pre-sign-up runs the first\n // time a user attempts to authenticate (before they exist in the User\n // Pool); pre-auth runs in subsequent authentication flows.\n const userPool = new UserPool(this, \"user-pool\", {\n lambdaTriggers: {\n preAuthentication: authLambda,\n preSignUp: authLambda,\n },\n });\n\n // These help ensure domain is deterministic but also unique. Key\n // assumption is that app/stack/stage combo are unique within Guardian.\n const domainPrefix = `com-gu-${app.toLowerCase()}-${scope.stage.toLowerCase()}`;\n\n const userPoolDomain = userPool.addDomain(\"domain\", {\n cognitoDomain: {\n domainPrefix: getUserPoolDomainPrefix(domainPrefix),\n },\n });\n\n const clientId = SecretValue.secretsManager(credentialsSecretsManagerPath, { jsonField: \"clientId\" });\n const clientSecret = SecretValue.secretsManager(credentialsSecretsManagerPath, { jsonField: \"clientSecret\" });\n\n const userPoolIdp = new UserPoolIdentityProviderGoogle(scope, \"google-idp\", {\n userPool: userPool,\n clientId: clientId.toString(),\n clientSecretValue: clientSecret,\n attributeMapping: {\n email: ProviderAttribute.GOOGLE_EMAIL,\n givenName: ProviderAttribute.GOOGLE_GIVEN_NAME,\n familyName: ProviderAttribute.GOOGLE_FAMILY_NAME,\n profilePicture: ProviderAttribute.GOOGLE_PICTURE,\n custom: {\n name: ProviderAttribute.GOOGLE_NAME,\n },\n },\n scopes: [\"openid\", \"email\", \"profile\"],\n });\n\n const userPoolClient = userPool.addClient(\"alb-client\", {\n supportedIdentityProviders: [UserPoolClientIdentityProvider.GOOGLE],\n generateSecret: true,\n oAuth: {\n callbackUrls: [`https://${props.googleAuth.domain}/oauth2/idpresponse`],\n },\n\n // Note: id and access validity token validity cannot be less than one\n // hour (this is the cognito cookie duration). To quickly invalidate\n // credentials, disable the user in Cognito. It might be that we want to\n // parameterise these going forward, but that would require Infosec\n // discussion.\n idTokenValidity: Duration.hours(1),\n accessTokenValidity: Duration.hours(1),\n refreshTokenValidity: Duration.days(7),\n });\n\n userPoolClient.node.addDependency(userPoolIdp);\n\n listener.addAction(\"CognitoAuth\", {\n action: new AuthenticateCognitoAction({\n userPool: userPool,\n userPoolClient: userPoolClient,\n userPoolDomain: userPoolDomain,\n next: ListenerAction.forward([targetGroup]),\n sessionTimeout: Duration.minutes(sessionTimeoutInMinutes),\n }),\n });\n\n // Need to give the ALB outbound access on 443 for the IdP endpoints.\n const idpEgressSecurityGroup = new GuHttpsEgressSecurityGroup(scope, \"ldp-access\", {\n app,\n vpc,\n });\n\n loadBalancer.addSecurityGroup(idpEgressSecurityGroup);\n }\n\n this.vpc = vpc;\n this.certificate = certificate;\n this.loadBalancer = loadBalancer;\n this.autoScalingGroup = autoScalingGroup;\n this.listener = listener;\n this.targetGroup = targetGroup;\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/patterns/ec2-app/base.ts"],"names":[],"mappings":";;;AA4VA,oDAMC;AAlWD,uGAAuG;AACvG,6CAA0D;AAE1D,iEAAsF;AACtF,yDAKiC;AAEjC,iDAAqD;AAErD,uFAA6F;AAC7F,uGAA2F;AAC3F,iDAA8D;AAC9D,uDAA+D;AAC/D,iDAAsD;AACtD,2CAAuC;AACvC,+CAAuF;AACvF,8CAAqD;AAErD,8DAA8E;AAE9E,4DAIqC;AAErC,gDAAkF;AAClF,8CAAsG;AAEtG,8CAAgF;AAChF,oDAA2D;AAC3D,kEAIwC;AAExC,uCAAwC;AAGxC,yDAAsE;AA6StE;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAe;IAClD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK;QACL,IAAI,EAAE,cAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACnB,WAAW,EAAE,iCAAiC,KAAK,CAAC,QAAQ,EAAE;KAC/D,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAa,QAAS,SAAQ,sBAAS;IAgBrC,YAAY,KAAc,EAAE,KAAoB;QAC9C,MAAM,EACJ,MAAM,EACN,iBAAiB,GAAG,IAAI,EACxB,GAAG;QACH,6FAA6F;QAC7F,kBAAkB,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EACvC,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,GAAG,EAAE,EACvB,OAAO,EAAE,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,CAAC,EAAE,EACtE,QAAQ,EAAE,YAAY,EACtB,WA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gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AAnUD,4BAmUC","sourcesContent":["/* eslint \"@guardian/tsdoc-required/tsdoc-required\": 2 -- to begin rolling this out for public APIs. */\nimport { Duration, SecretValue, Tags } from \"aws-cdk-lib\";\nimport type { BlockDevice, UpdatePolicy } from \"aws-cdk-lib/aws-autoscaling\";\nimport { AdditionalHealthCheckType, HealthChecks } from \"aws-cdk-lib/aws-autoscaling\";\nimport {\n ProviderAttribute,\n UserPool,\n UserPoolClientIdentityProvider,\n UserPoolIdentityProviderGoogle,\n} from \"aws-cdk-lib/aws-cognito\";\nimport type { InstanceType, IPeer, ISubnet, IVpc } from \"aws-cdk-lib/aws-ec2\";\nimport { Port, UserData } from \"aws-cdk-lib/aws-ec2\";\nimport type { HealthCheck as ALBHealthCheck } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport { ApplicationProtocol, ListenerAction } from \"aws-cdk-lib/aws-elasticloadbalancingv2\";\nimport { AuthenticateCognitoAction } from \"aws-cdk-lib/aws-elasticloadbalancingv2-actions\";\nimport { Effect, PolicyStatement } from \"aws-cdk-lib/aws-iam\";\nimport { Architecture, Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport { AccessScope, MetadataKeys, NAMED_SSM_PARAMETER_PATHS } from \"../../constants\";\nimport { GuCertificate } from \"../../constructs/acm\";\nimport type { GuUserDataProps } from \"../../constructs/autoscaling\";\nimport { GuAutoScalingGroup, GuUserData } from \"../../constructs/autoscaling\";\nimport type { Http4xxAlarmProps, Http5xxAlarmProps, NoMonitoring } from \"../../constructs/cloudwatch\";\nimport {\n GuAlb4xxPercentageAlarm,\n GuAlb5xxPercentageAlarm,\n GuUnhealthyInstancesAlarm,\n} from \"../../constructs/cloudwatch\";\nimport type { GuStack } from \"../../constructs/core\";\nimport { AppIdentity, GuLoggingStreamNameParameter } from \"../../constructs/core\";\nimport { GuHttpsEgressSecurityGroup, GuSecurityGroup, GuVpc, SubnetType } from \"../../constructs/ec2\";\nimport type { GuInstanceRoleProps, GuPolicy } from \"../../constructs/iam\";\nimport { GuGetPrivateConfigPolicy, GuInstanceRole } from \"../../constructs/iam\";\nimport { GuLambdaFunction } from \"../../constructs/lambda\";\nimport {\n GuApplicationLoadBalancer,\n GuApplicationTargetGroup,\n GuHttpsApplicationListener,\n} from \"../../constructs/loadbalancing\";\nimport type { WafProps } from \"../../constructs/loadbalancing\";\nimport { AppAccess } from \"../../types\";\nimport type { GuAsgCapacity, GuDomainName } from \"../../types\";\nimport type { AmigoProps } from \"../../types/amigo\";\nimport { getUserPoolDomainPrefix } from \"../../utils/cognito/cognito\";\n\n/**\n * To ship your application logs to ELK automatically, you must:\n *\n * 1. Set the `enabled` flag to true\n * 2. Include the `cdk-base` Amigo role in your AMI\n * 3. Log to `journald`. We recommend doing this by logging to `stdout` and\n * using `systemd` to start your app\n * 4. Confirm that your [[`systemdUnitName`]] is configured properly.\n *\n * Unless you have explicitly opted-out, appropriate IAM permissions for logging\n * to Kinesis will be configured automatically via the [[`GuEc2App`]] pattern.\n */\nexport interface ApplicationLoggingProps {\n /**\n * Enables forwarding of application logs to the Guardian ELK stack.\n *\n * Note, to work, you will need to also do the following non-CDK things:\n *\n * 1. Include the `cdk-base` Amigo role in your AMI.\n * 2. Log to `journald`. We recommend doing this by logging to `stdout` and\n * using `systemd` to start your app\n * 3. Confirm that your [[`systemdUnitName`]] is configured properly.\n *\n * Unless you have explicitly opted-out, appropriate IAM permissions for\n * logging to Kinesis will be configured automatically via the [[`GuEc2App`]]\n * pattern.\n *\n * @see https://github.com/guardian/amigo/tree/main/roles/cdk-base\n */\n enabled: boolean;\n /**\n * This needs to match the name of your SystemD unit.\n *\n * If your systemd unit is not `<app>.service` set this value.\n *\n * @defaultValue `<app>.service`\n */\n systemdUnitName?: string;\n}\n\n/**\n * @privateRemarks we should rename this to AlarmsProps.\n */\nexport interface Alarms {\n /**\n * Name of the target (SNS Topic) for alarm notifications.\n */\n snsTopicName: string;\n /**\n * Enable the 5xx alarm with settings.\n */\n http5xxAlarm: false | Http5xxAlarmProps;\n /**\n * Enable the 4xx alarm with settings.\n */\n http4xxAlarm?: false | Http4xxAlarmProps;\n /**\n * Enable the unhealthy instances alarm.\n */\n unhealthyInstancesAlarm: boolean;\n /**\n * Internal flag - users of this library should ignore this setting.\n */\n noMonitoring?: false;\n}\n\nexport interface GuEc2AppProps extends AppIdentity {\n /**\n * User data for the autoscaling group.\n */\n userData: GuUserDataProps | UserData;\n /**\n * Network access restrictions for your load balancer.\n *\n * Note, this merely provides defence in depth; you should NOT rely on network access restrictions alone for\n * restricting access. Use Google Auth for human access, or a suitable machine auth mechanism.\n */\n access: AppAccess;\n /**\n * The port your application runs on.\n */\n applicationPort: number;\n\n /**\n * Any additional permissions needed to run the application.\n */\n additionalPolicies?: GuPolicy[];\n\n /**\n * Enable and configure alarms.\n */\n monitoringConfiguration: Alarms | NoMonitoring;\n /**\n * EC2 instance type. Note, ensure your code is built for the same\n * architecture family (arm64 - 'Graviton' instances - or x64).\n */\n instanceType: InstanceType;\n /**\n * Enable and configures application logs.\n */\n applicationLogging?: ApplicationLoggingProps;\n\n /**\n * Enable access logging for this load balancer.\n * Access logs are written to an S3 bucket within your AWS account.\n * The bucket is created by {@link https://github.com/guardian/aws-account-setup}.\n * The logs are queryable via the `gucdk_access_logs` Athena database.\n *\n * @defaultValue true\n */\n withAccessLogging?: boolean;\n\n /**\n * Add block devices (additional storage).\n */\n blockDevices?: BlockDevice[];\n /**\n * Autoscaling group min and max sizes.\n */\n scaling: GuAsgCapacity;\n /**\n * Specify certificate for the load balancer.\n */\n certificateProps?: GuDomainName;\n\n /**\n * Configure AMIgo image recipe. This is only necessary if you are using GuCDK to generate your riff-raff.yaml file.\n */\n imageRecipe?: string | AmigoProps;\n /**\n * Specify the VPC to use.\n *\n * @see https://github.com/guardian/aws-account-setup\n */\n vpc?: IVpc;\n /**\n * Specify private subnets if using a non-default VPC or (generally\n * discouraged) to limit to a subset of the available subnets.\n */\n privateSubnets?: ISubnet[];\n\n /**\n * Specify private subnets if using a non-default VPC or (generally\n * discouraged) to limit to a subset of the available subnets.\n */\n publicSubnets?: ISubnet[];\n\n /**\n * Configure Google Auth.\n */\n googleAuth?: {\n /**\n * Enables Google Auth (via Cognito). **Additional MANUAL steps required -\n * see below.**\n *\n * Limits access to members of the allowed Google groups.\n *\n * Note, this does not currently support simultaneous machine access, so\n * only set to true if you only require staff access to your service, or are\n * supporting machine access in some other way.\n *\n * MANUAL STEPS: to get this to work, we need a Google Project and\n * associated credentials. Full instructions can be found here:\n *\n * https://docs.google.com/document/d/1_k1FSE52AZHXufWLTiKTI3xy5cGpziyHazSHTKrYfco/edit?usp=sharing\n *\n * DevX hope to automate this process in the near future.\n */\n enabled: true;\n /**\n * The domain users will access your service.\n *\n * Set this to the same as for certificateProps.\n */\n domain: string;\n /**\n * Groups used for membership checks.\n *\n * If specified, cannot be empty. Users must be a member of at least one\n * group to gain access.\n *\n * WARNING: groups must be specified with the `guardian.co.uk` domain, even\n * if that is the non-idiomatic choice for daily use.\n *\n * @defaultValue [`engineering@guardian.co.uk`]\n */\n allowedGroups?: string[];\n /**\n * The number of minutes before the session expires.\n *\n * Set this value to a safe period of time that revoked users\n * sessions will continue to function.\n *\n * NOTE: This value cannot be larger than 60 minutes.\n *\n * @defaultValue 15\n */\n sessionTimeoutInMinutes?: number;\n /**\n * Secrets Manager path containing Google OAuth2 Client credentials.\n *\n * NOTE: you do not need to set this value, but you DO need to generate and\n * store the associated credentials in Secrets Manager.\n *\n * Credentials should be stored in Secrets Manager as JSON:\n *\n * ```json\n * {\n * \"clientId\": \"my-client-id\",\n * \"clientSecret\": \"my-client-secret\"\n * }\n * ```\n *\n * @see `googleAuth.enabled` for how to generate.\n *\n * @defaultValue /:STAGE/:stack/:app/google-auth-credentials\n */\n credentialsSecretsManagerPath?: string;\n\n /**\n * When using Auth in the ALB, which stage of cognito-lambda to use.\n *\n * For most applications this should always be PROD, even in the CODE environments.\n *\n * @defaultValue PROD\n */\n cognitoAuthStage?: string;\n };\n\n /**\n * Specify custom healthcheck\n */\n healthcheck?: ALBHealthCheck;\n\n /**\n * Set http put response hop limit for the launch template.\n * It can be necessary to raise this value from the default of 1\n * for example when sharing the instance profile with a docker container running on the instance.\n */\n instanceMetadataHopLimit?: number;\n\n /**\n * Specify an update policy for the ASG created by this pattern.\n *\n * @see https://docs.aws.amazon.com/cdk/api/latest/docs/aws-autoscaling-readme.html#update-policy\n *\n * @defaultValue UpdatePolicy.none() - Cloudformation does not attempt to rotate instances in the ASG\n * and must rely on riffraff to do so.\n */\n updatePolicy?: UpdatePolicy;\n\n /**\n * You can specify how long after an instance reaches the InService state it waits before contributing\n * usage data to the aggregated metrics. This specified time is called the default instance warmup.\n * This keeps dynamic scaling from being affected by metrics for individual instances that aren't yet\n * handling application traffic and that might be experiencing temporarily high usage of compute resources.\n *\n * @see https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-default-instance-warmup.html\n */\n defaultInstanceWarmup?: Duration;\n\n /**\n * You can specify if the arn of this load balancer should be exposed for protection via WAF\n *\n * If this value changes, it is only picked up on WAF configuration redeploy.\n *\n * NB this parameter setting _alone_ is not sufficient to protect the application.\n * You must also ensure that the application and stage combination is present in the WAF\n * configuration.\n *\n * See https://github.com/guardian/waf/tree/main/lib\n *\n * There is a \"gotcha\" when migrating to this functionality. You may not change only the Logical\n * ID of an SSM Parameter (see https://docs.aws.amazon.com/cdk/v2/guide/identifiers.html) and the\n * parameter name must be of the required form, meaning you cannot have an alternate name.\n *\n * You can either:\n *\n * Remove the old param and immediately redeploy with the new param (this does not affect\n * protection unless and until the WAF configuration is redeployed)\n *\n * OR\n *\n * Create an escape hatch by overriding the logical id (see \"ssm param escape hatch\" test for example)\n **/\n waf?: WafProps;\n\n /**\n * How often to send EC2 metrics, such as CPU usage.\n * By default, AWS will produce `5Minute` granular metrics.\n *\n * It is recommended to produce `1Minute` granular metrics in production,\n * especially when using ASG metrics to trigger horizontal scaling as it allows for earlier scaling.\n *\n * @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html\n */\n instanceMetricGranularity: \"1Minute\" | \"5Minute\";\n}\n\n/**\n * Use this to allow specific CIDR ranges to access a load balancer over HTTPS\n */\nexport function restrictedCidrRanges(ranges: IPeer[]) {\n return ranges.map((range) => ({\n range,\n port: Port.tcp(443),\n description: `Allow access on port 443 from ${range.uniqueId}`,\n }));\n}\n\n/**\n * Pattern which creates the resources needed to run an application on EC2\n * behind a load balancer. For convenience, you may wish to use [[`GuPlayApp`]]\n * or [[`GuNodeApp`]], which extend this class.\n *\n * See props for further details.\n */\nexport class GuEc2App extends Construct {\n /*\n * These are public for now, as this allows users to\n * modify these constructs as desired to fit their\n * specific needs.\n * In the future, we might build functionality to better enable users\n * to access in-pattern constructs, but this would allow teams to be unblocked\n * in the short term.\n * */\n public readonly vpc: IVpc;\n public readonly certificate?: GuCertificate;\n public readonly loadBalancer: GuApplicationLoadBalancer;\n public readonly autoScalingGroup: GuAutoScalingGroup;\n public readonly listener: GuHttpsApplicationListener;\n public readonly targetGroup: GuApplicationTargetGroup;\n\n constructor(scope: GuStack, props: GuEc2AppProps) {\n const {\n access,\n withAccessLogging = true,\n app,\n // We should update this default once a significant number of apps have migrated to devx-logs\n applicationLogging = { enabled: false },\n applicationPort,\n blockDevices,\n certificateProps,\n instanceType,\n monitoringConfiguration,\n additionalPolicies = [],\n scaling: { minimumInstances, maximumInstances = minimumInstances * 2 },\n userData: userDataLike,\n imageRecipe,\n vpc = GuVpc.fromIdParameter(scope, AppIdentity.suffixText({ app }, \"VPC\")),\n privateSubnets = GuVpc.subnetsFromParameter(scope, { type: SubnetType.PRIVATE, app }),\n publicSubnets = GuVpc.subnetsFromParameter(scope, { type: SubnetType.PUBLIC, app }),\n instanceMetadataHopLimit,\n updatePolicy,\n defaultInstanceWarmup,\n instanceMetricGranularity,\n waf,\n } = props;\n\n super(scope, app); // The assumption is `app` is unique\n\n const userData = userDataLike instanceof UserData ? userDataLike : new GuUserData(scope, { ...userDataLike, app });\n\n AppAccess.validate(access);\n\n const certificate =\n typeof certificateProps !== \"undefined\"\n ? new GuCertificate(scope, {\n app,\n domainName: certificateProps.domainName,\n hostedZoneId: certificateProps.hostedZoneId,\n })\n : undefined;\n\n const maybePrivateConfigPolicy =\n userData instanceof GuUserData && userData.configuration\n ? [new GuGetPrivateConfigPolicy(scope, \"GetPrivateConfigFromS3Policy\", userData.configuration)]\n : [];\n\n const mergedRoleConfiguration: GuInstanceRoleProps = {\n additionalPolicies: maybePrivateConfigPolicy.concat(additionalPolicies),\n };\n\n const autoScalingGroup = new GuAutoScalingGroup(scope, \"AutoScalingGroup\", {\n app,\n vpc,\n instanceType,\n minimumInstances,\n maximumInstances,\n role: new GuInstanceRole(scope, { app, ...mergedRoleConfiguration }),\n\n // TODO should this be defaulted at pattern or construct level?\n healthChecks: HealthChecks.withAdditionalChecks({\n additionalTypes: [AdditionalHealthCheckType.ELB],\n gracePeriod: Duration.minutes(2),\n }),\n\n userData: userData instanceof GuUserData ? userData.userData : userData,\n vpcSubnets: { subnets: privateSubnets },\n ...(blockDevices && { blockDevices }),\n imageRecipe,\n httpPutResponseHopLimit: instanceMetadataHopLimit,\n updatePolicy,\n defaultInstanceWarmup,\n instanceMetricGranularity,\n });\n\n // This allows automatic shipping of instance Cloud Init logs when using the\n // `cdk-base` Amigo role on your AMI.\n Tags.of(autoScalingGroup).add(\n MetadataKeys.LOG_KINESIS_STREAM_NAME,\n GuLoggingStreamNameParameter.getInstance(scope).valueAsString,\n );\n\n if (applicationLogging.enabled) {\n // This allows automatic shipping of application logs when using the\n // `cdk-base` Amigo role on your AMI.\n Tags.of(autoScalingGroup).add(\n MetadataKeys.SYSTEMD_UNIT,\n applicationLogging.systemdUnitName ? `${applicationLogging.systemdUnitName}.service` : `${app}.service`,\n );\n }\n\n const loadBalancer = new GuApplicationLoadBalancer(scope, \"LoadBalancer\", {\n app,\n vpc,\n // Setting internetFacing to true does not necessarily allow public access to the load balancer itself. That is handled by the listener's `open` prop.\n internetFacing: access.scope !== AccessScope.INTERNAL,\n vpcSubnets: {\n subnets: access.scope === AccessScope.INTERNAL ? privateSubnets : publicSubnets,\n },\n withAccessLogging,\n waf,\n });\n\n const targetGroup = new GuApplicationTargetGroup(scope, \"TargetGroup\", {\n app,\n vpc,\n protocol: ApplicationProtocol.HTTP,\n targets: [autoScalingGroup],\n port: applicationPort,\n healthCheck: props.healthcheck,\n });\n\n const listener = new GuHttpsApplicationListener(scope, \"Listener\", {\n app,\n loadBalancer,\n certificate,\n targetGroup,\n // When open=true, AWS will create a security group which allows all inbound traffic over HTTPS\n open: access.scope === AccessScope.PUBLIC && typeof certificate !== \"undefined\",\n });\n\n // Since AWS won't create a security group automatically when open=false, we need to add our own\n if (access.scope !== AccessScope.PUBLIC) {\n loadBalancer.addSecurityGroup(\n new GuSecurityGroup(scope, `${access.scope}IngressSecurityGroup`, {\n app,\n vpc,\n description: \"Allow restricted ingress from CIDR ranges\",\n allowAllOutbound: false,\n ingresses: restrictedCidrRanges(access.cidrRanges),\n }),\n );\n }\n\n if (!monitoringConfiguration.noMonitoring) {\n const { http5xxAlarm, http4xxAlarm, snsTopicName, unhealthyInstancesAlarm } = monitoringConfiguration;\n\n if (http4xxAlarm) {\n new GuAlb4xxPercentageAlarm(scope, {\n app,\n loadBalancer,\n snsTopicName,\n ...http4xxAlarm,\n });\n }\n if (http5xxAlarm) {\n new GuAlb5xxPercentageAlarm(scope, {\n app,\n loadBalancer,\n snsTopicName,\n ...http5xxAlarm,\n });\n }\n if (unhealthyInstancesAlarm) {\n new GuUnhealthyInstancesAlarm(scope, {\n app,\n targetGroup,\n snsTopicName,\n });\n }\n }\n\n if (props.googleAuth?.enabled) {\n const prefix = `/${scope.stage}/${scope.stack}/${app}`;\n\n const {\n allowedGroups = [\"engineering@guardian.co.uk\"],\n sessionTimeoutInMinutes = 15,\n credentialsSecretsManagerPath = `${prefix}/google-auth-credentials`,\n } = props.googleAuth;\n\n if (sessionTimeoutInMinutes > 60) {\n throw new Error(\"googleAuth.sessionTimeoutInMinutes must be <= 60!\");\n }\n\n if (allowedGroups.length < 1) {\n throw new Error(\"googleAuth.allowedGroups cannot be empty!\");\n }\n\n if (allowedGroups.find((group) => !group.endsWith(\"@guardian.co.uk\"))) {\n throw new Error(\"googleAuth.allowedGroups must use the @guardian.co.uk domain.\");\n }\n\n const deployToolsAccountId = StringParameter.fromStringParameterName(\n scope,\n \"deploy-tools-account-id-parameter\",\n NAMED_SSM_PARAMETER_PATHS.DeployToolsAccountId.path,\n );\n\n const cognitoAuthStage = props.googleAuth.cognitoAuthStage ?? \"PROD\";\n\n // See https://github.com/guardian/cognito-auth-lambdas for the source\n // code here. ARN format is:\n // arn:aws:lambda:aws-region:acct-id:function:helloworld.\n const gatekeeperFunctionArn = `arn:aws:lambda:eu-west-1:${deployToolsAccountId.stringValue}:function:deploy-${cognitoAuthStage}-gatekeeper-lambda`;\n\n // Note, handler and filename must match here:\n // https://github.com/guardian/cognito-auth-lambdas.\n const authLambda = new GuLambdaFunction(scope, \"auth-lambda\", {\n app: app,\n memorySize: 128,\n handler: \"bootstrap\",\n runtime: Runtime.PROVIDED_AL2023,\n fileName: `deploy/${cognitoAuthStage}/cognito-lambda/devx-cognito-lambda-amd64-v2.zip`,\n withoutFilePrefix: true,\n withoutArtifactUpload: true,\n bucketNamePath: NAMED_SSM_PARAMETER_PATHS.OrganisationDistributionBucket.path,\n architecture: Architecture.X86_64,\n environment: {\n ALLOWED_GROUPS: allowedGroups.join(\",\"),\n GATEKEEPER_FUNCTION_ARN: gatekeeperFunctionArn,\n },\n });\n\n Tags.of(authLambda).add(\"Owner\", \"DevX\");\n\n authLambda.addToRolePolicy(\n new PolicyStatement({\n effect: Effect.ALLOW,\n actions: [\"lambda:InvokeFunction\"],\n resources: [gatekeeperFunctionArn],\n }),\n );\n\n // Cognito user pool. We require both lambdas: pre-sign-up runs the first\n // time a user attempts to authenticate (before they exist in the User\n // Pool); pre-auth runs in subsequent authentication flows.\n const userPool = new UserPool(this, \"user-pool\", {\n lambdaTriggers: {\n preAuthentication: authLambda,\n preSignUp: authLambda,\n },\n });\n\n // These help ensure domain is deterministic but also unique. Key\n // assumption is that app/stack/stage combo are unique within Guardian.\n const domainPrefix = `com-gu-${app.toLowerCase()}-${scope.stage.toLowerCase()}`;\n\n const userPoolDomain = userPool.addDomain(\"domain\", {\n cognitoDomain: {\n domainPrefix: getUserPoolDomainPrefix(domainPrefix),\n },\n });\n\n const clientId = SecretValue.secretsManager(credentialsSecretsManagerPath, { jsonField: \"clientId\" });\n const clientSecret = SecretValue.secretsManager(credentialsSecretsManagerPath, { jsonField: \"clientSecret\" });\n\n const userPoolIdp = new UserPoolIdentityProviderGoogle(scope, \"google-idp\", {\n userPool: userPool,\n clientId: clientId.toString(),\n clientSecretValue: clientSecret,\n attributeMapping: {\n email: ProviderAttribute.GOOGLE_EMAIL,\n givenName: ProviderAttribute.GOOGLE_GIVEN_NAME,\n familyName: ProviderAttribute.GOOGLE_FAMILY_NAME,\n profilePicture: ProviderAttribute.GOOGLE_PICTURE,\n custom: {\n name: ProviderAttribute.GOOGLE_NAME,\n },\n },\n scopes: [\"openid\", \"email\", \"profile\"],\n });\n\n const userPoolClient = userPool.addClient(\"alb-client\", {\n supportedIdentityProviders: [UserPoolClientIdentityProvider.GOOGLE],\n generateSecret: true,\n oAuth: {\n callbackUrls: [`https://${props.googleAuth.domain}/oauth2/idpresponse`],\n },\n\n // Note: id and access validity token validity cannot be less than one\n // hour (this is the cognito cookie duration). To quickly invalidate\n // credentials, disable the user in Cognito. It might be that we want to\n // parameterise these going forward, but that would require Infosec\n // discussion.\n idTokenValidity: Duration.hours(1),\n accessTokenValidity: Duration.hours(1),\n refreshTokenValidity: Duration.days(7),\n });\n\n userPoolClient.node.addDependency(userPoolIdp);\n\n listener.addAction(\"CognitoAuth\", {\n action: new AuthenticateCognitoAction({\n userPool: userPool,\n userPoolClient: userPoolClient,\n userPoolDomain: userPoolDomain,\n next: ListenerAction.forward([targetGroup]),\n sessionTimeout: Duration.minutes(sessionTimeoutInMinutes),\n }),\n });\n\n // Need to give the ALB outbound access on 443 for the IdP endpoints.\n const idpEgressSecurityGroup = new GuHttpsEgressSecurityGroup(scope, \"ldp-access\", {\n app,\n vpc,\n });\n\n loadBalancer.addSecurityGroup(idpEgressSecurityGroup);\n }\n\n this.vpc = vpc;\n this.certificate = certificate;\n this.loadBalancer = loadBalancer;\n this.autoScalingGroup = autoScalingGroup;\n this.listener = listener;\n this.targetGroup = targetGroup;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoscalingDeployment = exports.uploadAutoscalingArtifact = void 0;
3
+ exports.uploadAutoscalingArtifact = uploadAutoscalingArtifact;
4
+ exports.autoscalingDeployment = autoscalingDeployment;
4
5
  function uploadAutoscalingArtifact(asg) {
5
6
  const { app } = asg;
6
7
  const { stack, region } = asg.stack;
@@ -20,7 +21,6 @@ function uploadAutoscalingArtifact(asg) {
20
21
  },
21
22
  };
22
23
  }
23
- exports.uploadAutoscalingArtifact = uploadAutoscalingArtifact;
24
24
  function autoscalingDeployment(asg, { name: cfnDeployName }) {
25
25
  const { app } = asg;
26
26
  const { stack, region } = asg.stack;
@@ -41,5 +41,4 @@ function autoscalingDeployment(asg, { name: cfnDeployName }) {
41
41
  },
42
42
  };
43
43
  }
44
- exports.autoscalingDeployment = autoscalingDeployment;
45
44
  //# sourceMappingURL=autoscaling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoscaling.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/autoscaling.ts"],"names":[],"mappings":";;;AAIA,SAAgB,yBAA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AAC;YAC7B,gBAAgB,EAAE,GAAG;SACtB;KACF,CAAC;AACJ,CAAC;AAvBD,sDAuBC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport type { GuStack } from \"../../constructs/core\";\nimport type { RiffRaffDeployment } from \"../types\";\n\nexport function uploadAutoscalingArtifact(asg: GuAutoScalingGroup): RiffRaffDeployment {\n const { app } = asg;\n const { stack, region } = asg.stack as GuStack;\n\n return {\n name: [\"asg-upload\", region, stack, app].join(\"-\"),\n props: {\n type: \"autoscaling\",\n actions: [\"uploadArtifacts\"],\n regions: new Set([region]),\n stacks: new Set([stack]),\n app,\n parameters: {\n bucketSsmLookup: true,\n prefixApp: true,\n },\n contentDirectory: app,\n },\n };\n}\n\nexport function autoscalingDeployment(\n asg: GuAutoScalingGroup,\n { name: cfnDeployName }: RiffRaffDeployment,\n): RiffRaffDeployment {\n const { app } = asg;\n const { stack, region } = asg.stack as GuStack;\n\n return {\n name: [\"asg-update\", region, stack, app].join(\"-\"),\n props: {\n type: \"autoscaling\",\n actions: [\"deploy\"],\n regions: new Set([region]),\n stacks: new Set([stack]),\n app,\n parameters: {\n bucketSsmLookup: true,\n prefixApp: true,\n },\n dependencies: [cfnDeployName],\n contentDirectory: app,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"autoscaling.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/autoscaling.ts"],"names":[],"mappings":";;AAIA,8DAmBC;AAED,sDAuBC;AA5CD,SAAgB,yBAAyB,CAAC,GAAuB;IAC/D,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAgB,CAAC;IAE/C,OAAO;QACL,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAClD,KAAK,EAAE;YACL,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,CAAC,iBAAiB,CAAC;YAC5B,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB,GAAG;YACH,UAAU,EAAE;gBACV,eAAe,EAAE,IAAI;gBACrB,SAAS,EAAE,IAAI;aAChB;YACD,gBAAgB,EAAE,GAAG;SACtB;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,qBAAqB,CACnC,GAAuB,EACvB,EAAE,IAAI,EAAE,aAAa,EAAsB;IAE3C,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAgB,CAAC;IAE/C,OAAO;QACL,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAClD,KAAK,EAAE;YACL,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,CAAC,QAAQ,CAAC;YACnB,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB,GAAG;YACH,UAAU,EAAE;gBACV,eAAe,EAAE,IAAI;gBACrB,SAAS,EAAE,IAAI;aAChB;YACD,YAAY,EAAE,CAAC,aAAa,CAAC;YAC7B,gBAAgB,EAAE,GAAG;SACtB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport type { GuStack } from \"../../constructs/core\";\nimport type { RiffRaffDeployment } from \"../types\";\n\nexport function uploadAutoscalingArtifact(asg: GuAutoScalingGroup): RiffRaffDeployment {\n const { app } = asg;\n const { stack, region } = asg.stack as GuStack;\n\n return {\n name: [\"asg-upload\", region, stack, app].join(\"-\"),\n props: {\n type: \"autoscaling\",\n actions: [\"uploadArtifacts\"],\n regions: new Set([region]),\n stacks: new Set([stack]),\n app,\n parameters: {\n bucketSsmLookup: true,\n prefixApp: true,\n },\n contentDirectory: app,\n },\n };\n}\n\nexport function autoscalingDeployment(\n asg: GuAutoScalingGroup,\n { name: cfnDeployName }: RiffRaffDeployment,\n): RiffRaffDeployment {\n const { app } = asg;\n const { stack, region } = asg.stack as GuStack;\n\n return {\n name: [\"asg-update\", region, stack, app].join(\"-\"),\n props: {\n type: \"autoscaling\",\n actions: [\"deploy\"],\n regions: new Set([region]),\n stacks: new Set([stack]),\n app,\n parameters: {\n bucketSsmLookup: true,\n prefixApp: true,\n },\n dependencies: [cfnDeployName],\n contentDirectory: app,\n },\n };\n}\n"]}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMinInstancesInServiceParameters = exports.getAmiParameters = exports.cloudFormationDeployment = void 0;
3
+ exports.cloudFormationDeployment = cloudFormationDeployment;
4
+ exports.getAmiParameters = getAmiParameters;
5
+ exports.getMinInstancesInServiceParameters = getMinInstancesInServiceParameters;
4
6
  const string_1 = require("../../utils/string");
5
7
  function cloudFormationDeployment(cdkStacks, dependencies, contentDirectory) {
6
8
  // The stacks in `cdkStacks` only differ by stage, so we can just use the first item in the list for key information.
@@ -30,7 +32,6 @@ function cloudFormationDeployment(cdkStacks, dependencies, contentDirectory) {
30
32
  },
31
33
  };
32
34
  }
33
- exports.cloudFormationDeployment = cloudFormationDeployment;
34
35
  function getAmiParameters(autoScalingGroups) {
35
36
  return autoScalingGroups.reduce((acc, asg) => {
36
37
  const { imageRecipe, app, amiParameter } = asg;
@@ -52,7 +53,6 @@ function getAmiParameters(autoScalingGroups) {
52
53
  };
53
54
  }, {});
54
55
  }
55
- exports.getAmiParameters = getAmiParameters;
56
56
  function getMinInstancesInServiceParameters(cfnParameters) {
57
57
  const response = {};
58
58
  cfnParameters.forEach((cfnParam, cfnParamName) => {
@@ -61,5 +61,4 @@ function getMinInstancesInServiceParameters(cfnParameters) {
61
61
  });
62
62
  return response;
63
63
  }
64
- exports.getMinInstancesInServiceParameters = getMinInstancesInServiceParameters;
65
64
  //# sourceMappingURL=cloudformation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudformation.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":";;;AAEA,+CAAiD;AAGjD,SAAgB,wBAAwB,CACtC,SAAwC,EACxC,YAAkC,EAClC,gBAAwB;IAExB,qHAAqH;IACrH,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAE7B,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;KAC1F;IAED,MAAM,EACJ,MAAM,EACN,KAAK,EACL,WAAW,EAAE,EAAE,IAAI,EAAE,GACtB,GAAG,QAAQ,CAAC;IAEb,MAAM,cAAc,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAEzC,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,GA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AC,OAAO,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE;QAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7B,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAXD,gFAWC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport type { GuAsgMinInstancesInServiceParameterExperimental } from \"../../experimental/patterns/ec2-app\";\nimport { toKebabCase } from \"../../utils/string\";\nimport type { CdkStacksDifferingOnlyByStage, RiffRaffDeployment, RiffRaffDeploymentParameters } from \"../types\";\n\nexport function cloudFormationDeployment(\n cdkStacks: CdkStacksDifferingOnlyByStage,\n dependencies: RiffRaffDeployment[],\n contentDirectory: string,\n): RiffRaffDeployment {\n // The stacks in `cdkStacks` only differ by stage, so we can just use the first item in the list for key information.\n const [cdkStack] = cdkStacks;\n\n if (!cdkStack) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n const {\n region,\n stack,\n constructor: { name },\n } = cdkStack;\n\n const kebabClassName = toKebabCase(name);\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 getAmiParameters(autoScalingGroups: GuAutoScalingGroup[]): RiffRaffDeploymentParameters {\n return autoScalingGroups.reduce<RiffRaffDeploymentParameters>((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 // In YAML `true` is a Boolean. Riff-Raff expects a String here, so call `toString` to make it `'true'`.\n const Encrypted = (typeof imageRecipe === \"string\" ? true : (imageRecipe.Encrypted ?? true)).toString();\n\n return {\n ...acc,\n [amiParameter.node.id]: {\n BuiltBy: \"amigo\",\n AmigoStage,\n Recipe,\n Encrypted,\n },\n };\n }, {});\n}\n\nexport function getMinInstancesInServiceParameters(\n cfnParameters: Map<string, GuAsgMinInstancesInServiceParameterExperimental>,\n): RiffRaffDeploymentParameters {\n const response: RiffRaffDeploymentParameters = {};\n\n cfnParameters.forEach((cfnParam, cfnParamName) => {\n const app = cfnParam.asg.app;\n response[cfnParamName] = { App: app };\n });\n\n return response;\n}\n"]}
1
+ {"version":3,"file":"cloudformation.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/cloudformation.ts"],"names":[],"mappings":";;AAKA,4DA2CC;AAED,4CAwBC;AAED,gFAWC;AArFD,+CAAiD;AAGjD,SAAgB,wBAAwB,CACtC,SAAwC,EACxC,YAAkC,EAClC,gBAAwB;IAExB,qHAAqH;IACrH,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAE7B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,EACJ,MAAM,EACN,KAAK,EACL,WAAW,EAAE,EAAE,IAAI,EAAE,GACtB,GAAG,QAAQ,CAAC;IAEb,MAAM,cAAc,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAEzC,MAAM,kBAAkB,GAAG,SAAS,CAAC,MAAM,CACzC,CAAC,GAAG,E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AAI,MAAM,CAAC,CAAC;QAEjG,wGAAwG;QACxG,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAExG,OAAO;YACL,GAAG,GAAG;YACN,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;gBACtB,OAAO,EAAE,OAAO;gBAChB,UAAU;gBACV,MAAM;gBACN,SAAS;aACV;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAgB,kCAAkC,CAChD,aAA2E;IAE3E,MAAM,QAAQ,GAAiC,EAAE,CAAC;IAElD,aAAa,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE;QAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7B,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport type { GuAsgMinInstancesInServiceParameterExperimental } from \"../../experimental/patterns/ec2-app\";\nimport { toKebabCase } from \"../../utils/string\";\nimport type { CdkStacksDifferingOnlyByStage, RiffRaffDeployment, RiffRaffDeploymentParameters } from \"../types\";\n\nexport function cloudFormationDeployment(\n cdkStacks: CdkStacksDifferingOnlyByStage,\n dependencies: RiffRaffDeployment[],\n contentDirectory: string,\n): RiffRaffDeployment {\n // The stacks in `cdkStacks` only differ by stage, so we can just use the first item in the list for key information.\n const [cdkStack] = cdkStacks;\n\n if (!cdkStack) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n const {\n region,\n stack,\n constructor: { name },\n } = cdkStack;\n\n const kebabClassName = toKebabCase(name);\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 getAmiParameters(autoScalingGroups: GuAutoScalingGroup[]): RiffRaffDeploymentParameters {\n return autoScalingGroups.reduce<RiffRaffDeploymentParameters>((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 // In YAML `true` is a Boolean. Riff-Raff expects a String here, so call `toString` to make it `'true'`.\n const Encrypted = (typeof imageRecipe === \"string\" ? true : (imageRecipe.Encrypted ?? true)).toString();\n\n return {\n ...acc,\n [amiParameter.node.id]: {\n BuiltBy: \"amigo\",\n AmigoStage,\n Recipe,\n Encrypted,\n },\n };\n }, {});\n}\n\nexport function getMinInstancesInServiceParameters(\n cfnParameters: Map<string, GuAsgMinInstancesInServiceParameterExperimental>,\n): RiffRaffDeploymentParameters {\n const response: RiffRaffDeploymentParameters = {};\n\n cfnParameters.forEach((cfnParam, cfnParamName) => {\n const app = cfnParam.asg.app;\n response[cfnParamName] = { App: app };\n });\n\n return response;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateLambdaDeployment = exports.uploadLambdaArtifact = void 0;
3
+ exports.uploadLambdaArtifact = uploadLambdaArtifact;
4
+ exports.updateLambdaDeployment = updateLambdaDeployment;
4
5
  const locationProps = (lambda) => {
5
6
  const bucketProp = lambda.bucketNamePath === undefined
6
7
  ? {
@@ -46,7 +47,6 @@ function uploadLambdaArtifact(lambda) {
46
47
  },
47
48
  };
48
49
  }
49
- exports.uploadLambdaArtifact = uploadLambdaArtifact;
50
50
  function updateLambdaDeployment(lambda, { name: cfnDeployName }) {
51
51
  const { app, fileName } = lambda;
52
52
  const { stack, region } = lambda.stack;
@@ -68,5 +68,4 @@ function updateLambdaDeployment(lambda, { name: cfnDeployName }) {
68
68
  },
69
69
  };
70
70
  }
71
- exports.updateLambdaDeployment = updateLambdaDeployment;
72
71
  //# sourceMappingURL=lambda.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/lambda.ts"],"names":[],"mappings":";;;AAYA,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAmB,EAAE;IAClE,MAAM,UAAU,GACd,MAAM,CAAC,cAAc,KAAK,SAAS;QACjC,CAAC,CAAC;YACE,eAAe,EAAE,IAAI;SACtB;QACH,CAAC,CAAC;YACE,YAAY,EAAE,MAAM,CAAC,cAAc;SACpC,CAAC;IAER;;;;OAIG;IACH,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB;QAC1C,CAAC,CAAC;YACE,gBAAgB,EAAE,KAAK;YACvB,cAAc,EAAE,KAAK;YACrB,gBAAgB,EAAE,KAAK;SACxB;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,GAAG,UAAU;QACb,GAAG,WAAW;KACf,CAAC;AACJ,CAAC,CAAC;AAEF,SAAgB,oBAAoB,CAAC,MAAwB;IAC3D,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAgB,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sourcesContent":["import type { GuStack } from \"../../constructs/core\";\nimport type { GuLambdaFunction } from \"../../constructs/lambda\";\nimport type { RiffRaffDeployment } from \"../types\";\n\ninterface S3LocationProps {\n bucketSsmLookup?: boolean;\n bucketSsmKey?: string;\n prefixStackToKey?: boolean;\n prefixAppToKey?: boolean;\n prefixStageToKey?: boolean;\n}\n\nconst locationProps = (lambda: GuLambdaFunction): S3LocationProps => {\n const bucketProp =\n lambda.bucketNamePath === undefined\n ? {\n bucketSsmLookup: true,\n }\n : {\n bucketSsmKey: lambda.bucketNamePath,\n };\n\n /**\n * If the lambda has a file prefix, we don't want to prefix the key with the stack, app or stage.\n * The default value for these properties is `true`, so we don't need to set them explicitly if\n * we *do* want to add the prefixes (and RiffRaff will complain if we add them).\n */\n const prefixProps = lambda.withoutFilePrefix\n ? {\n prefixStackToKey: false,\n prefixAppToKey: false,\n prefixStageToKey: false,\n }\n : {};\n\n return {\n ...bucketProp,\n ...prefixProps,\n };\n};\n\nexport function uploadLambdaArtifact(lambda: GuLambdaFunction): RiffRaffDeployment {\n const { app, fileName } = lambda;\n const { stack, region } = lambda.stack as GuStack;\n\n return {\n name: [\"lambda-upload\", region, stack, app].join(\"-\"),\n props: {\n type: \"aws-lambda\",\n stacks: new Set([stack]),\n regions: new Set([region]),\n app,\n contentDirectory: app,\n parameters: {\n ...locationProps(lambda),\n lookupByTags: true,\n fileName,\n },\n actions: [\"uploadLambda\"],\n },\n };\n}\n\nexport function updateLambdaDeployment(\n lambda: GuLambdaFunction,\n { name: cfnDeployName }: RiffRaffDeployment,\n): RiffRaffDeployment {\n const { app, fileName } = lambda;\n const { stack, region } = lambda.stack as GuStack;\n\n return {\n name: [\"lambda-update\", region, stack, app].join(\"-\"),\n props: {\n type: \"aws-lambda\",\n stacks: new Set([stack]),\n regions: new Set([region]),\n app,\n contentDirectory: app,\n parameters: {\n ...locationProps(lambda),\n lookupByTags: true,\n fileName,\n },\n actions: [\"updateLambda\"],\n dependencies: [cfnDeployName],\n },\n };\n}\n"]}
1
+ {"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/lambda.ts"],"names":[],"mappings":";;AAyCA,oDAoBC;AAED,wDAwBC;AA3ED,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAmB,EAAE;IAClE,MAAM,UAAU,GACd,MAAM,CAAC,cAAc,KAAK,SAAS;QACjC,CAAC,CAAC;YACE,eAAe,EAAE,IAAI;SACtB;QACH,CAAC,CAAC;YACE,YAAY,EAAE,MAAM,CAAC,cAAc;SACpC,CAAC;IAER;;;;OAIG;IACH,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB;QAC1C,CAAC,CAAC;YACE,gBAAgB,EAAE,KAAK;YACvB,cAAc,EAAE,KAAK;YACrB,gBAAgB,EAAE,KAAK;SACxB;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,GAAG,UAAU;QACb,GAAG,WAAW;KACf,CAAC;AACJ,CAAC,CAAC;AAEF,SAAgB,oBAAoB,CAAC,MAAwB;IAC3D,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAgB,CAAC;IAElD,OAAO;QACL,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACrD,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;YAC1B,GAAG;YACH,gBAAgB,EAAE,GAAG;YACrB,UAAU,EAAE;gBACV,GAAG,aAAa,CAAC,MAAM,CAAC;gBACxB,YAAY,EAAE,IAAI;gBAClB,QAAQ;aACT;YACD,OAAO,EAAE,CAAC,cAAc,CAAC;SAC1B;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,sBAAsB,CACpC,MAAwB,EACxB,EAAE,IAAI,EAAE,aAAa,EAAsB;IAE3C,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAgB,CAAC;IAElD,OAAO;QACL,IAAI,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACrD,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;YAC1B,GAAG;YACH,gBAAgB,EAAE,GAAG;YACrB,UAAU,EAAE;gBACV,GAAG,aAAa,CAAC,MAAM,CAAC;gBACxB,YAAY,EAAE,IAAI;gBAClB,QAAQ;aACT;YACD,OAAO,EAAE,CAAC,cAAc,CAAC;YACzB,YAAY,EAAE,CAAC,aAAa,CAAC;SAC9B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { GuStack } from \"../../constructs/core\";\nimport type { GuLambdaFunction } from \"../../constructs/lambda\";\nimport type { RiffRaffDeployment } from \"../types\";\n\ninterface S3LocationProps {\n bucketSsmLookup?: boolean;\n bucketSsmKey?: string;\n prefixStackToKey?: boolean;\n prefixAppToKey?: boolean;\n prefixStageToKey?: boolean;\n}\n\nconst locationProps = (lambda: GuLambdaFunction): S3LocationProps => {\n const bucketProp =\n lambda.bucketNamePath === undefined\n ? {\n bucketSsmLookup: true,\n }\n : {\n bucketSsmKey: lambda.bucketNamePath,\n };\n\n /**\n * If the lambda has a file prefix, we don't want to prefix the key with the stack, app or stage.\n * The default value for these properties is `true`, so we don't need to set them explicitly if\n * we *do* want to add the prefixes (and RiffRaff will complain if we add them).\n */\n const prefixProps = lambda.withoutFilePrefix\n ? {\n prefixStackToKey: false,\n prefixAppToKey: false,\n prefixStageToKey: false,\n }\n : {};\n\n return {\n ...bucketProp,\n ...prefixProps,\n };\n};\n\nexport function uploadLambdaArtifact(lambda: GuLambdaFunction): RiffRaffDeployment {\n const { app, fileName } = lambda;\n const { stack, region } = lambda.stack as GuStack;\n\n return {\n name: [\"lambda-upload\", region, stack, app].join(\"-\"),\n props: {\n type: \"aws-lambda\",\n stacks: new Set([stack]),\n regions: new Set([region]),\n app,\n contentDirectory: app,\n parameters: {\n ...locationProps(lambda),\n lookupByTags: true,\n fileName,\n },\n actions: [\"uploadLambda\"],\n },\n };\n}\n\nexport function updateLambdaDeployment(\n lambda: GuLambdaFunction,\n { name: cfnDeployName }: RiffRaffDeployment,\n): RiffRaffDeployment {\n const { app, fileName } = lambda;\n const { stack, region } = lambda.stack as GuStack;\n\n return {\n name: [\"lambda-update\", region, stack, app].join(\"-\"),\n props: {\n type: \"aws-lambda\",\n stacks: new Set([stack]),\n regions: new Set([region]),\n app,\n contentDirectory: app,\n parameters: {\n ...locationProps(lambda),\n lookupByTags: true,\n fileName,\n },\n actions: [\"updateLambda\"],\n dependencies: [cfnDeployName],\n },\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateDeploymentParameters = void 0;
3
+ exports.updateDeploymentParameters = updateDeploymentParameters;
4
4
  function updateDeploymentParameters(allDeployments, deploymentToUpdate, additionalParametersToApply) {
5
5
  const currentDeployment = allDeployments.get(deploymentToUpdate.name);
6
6
  if (!currentDeployment) {
@@ -14,5 +14,4 @@ function updateDeploymentParameters(allDeployments, deploymentToUpdate, addition
14
14
  },
15
15
  });
16
16
  }
17
- exports.updateDeploymentParameters = updateDeploymentParameters;
18
17
  //# sourceMappingURL=update-parameters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-parameters.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/update-parameters.ts"],"names":[],"mappings":";;;AAEA,SAAgB,0BAA0B,CACxC,cAAmC,EACnC,kBAAsC,EACtC,2BAAyD;IAEzD,MAAM,iBAAiB,GAAG,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,6BAA6B,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;KACzE;IAED,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE;QAC1C,GAAG,iBAAiB;QACpB,UAAU,EAAE;YACV,GAAG,iBAAiB,CAAC,UAAU;YAC/B,GAAG,2BAA2B;SAC/B;KACF,CAAC,CAAC;AACL,CAAC;AAjBD,gEAiBC","sourcesContent":["import type { RiffRaffDeployment, RiffRaffDeploymentParameters, RiffRaffDeployments } from \"../types\";\n\nexport function updateDeploymentParameters(\n allDeployments: RiffRaffDeployments,\n deploymentToUpdate: RiffRaffDeployment,\n additionalParametersToApply: RiffRaffDeploymentParameters,\n) {\n const currentDeployment = allDeployments.get(deploymentToUpdate.name);\n if (!currentDeployment) {\n throw new Error(`Unable to find deployment ${deploymentToUpdate.name}`);\n }\n\n allDeployments.set(deploymentToUpdate.name, {\n ...currentDeployment,\n parameters: {\n ...currentDeployment.parameters,\n ...additionalParametersToApply,\n },\n });\n}\n"]}
1
+ {"version":3,"file":"update-parameters.js","sourceRoot":"","sources":["../../../src/riff-raff-yaml-file/deployments/update-parameters.ts"],"names":[],"mappings":";;AAEA,gEAiBC;AAjBD,SAAgB,0BAA0B,CACxC,cAAmC,EACnC,kBAAsC,EACtC,2BAAyD;IAEzD,MAAM,iBAAiB,GAAG,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,6BAA6B,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE;QAC1C,GAAG,iBAAiB;QACpB,UAAU,EAAE;YACV,GAAG,iBAAiB,CAAC,UAAU;YAC/B,GAAG,2BAA2B;SAC/B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { RiffRaffDeployment, RiffRaffDeploymentParameters, RiffRaffDeployments } from \"../types\";\n\nexport function updateDeploymentParameters(\n allDeployments: RiffRaffDeployments,\n deploymentToUpdate: RiffRaffDeployment,\n additionalParametersToApply: RiffRaffDeploymentParameters,\n) {\n const currentDeployment = allDeployments.get(deploymentToUpdate.name);\n if (!currentDeployment) {\n throw new Error(`Unable to find deployment ${deploymentToUpdate.name}`);\n }\n\n allDeployments.set(deploymentToUpdate.name, {\n ...currentDeployment,\n parameters: {\n ...currentDeployment.parameters,\n ...additionalParametersToApply,\n },\n });\n}\n"]}
@@ -1,26 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupByRiffRaffProjectName = exports.groupByRegion = exports.groupByStageTag = exports.groupByStackTag = exports.groupByClassName = void 0;
3
+ exports.groupByClassName = groupByClassName;
4
+ exports.groupByStackTag = groupByStackTag;
5
+ exports.groupByStageTag = groupByStageTag;
6
+ exports.groupByRegion = groupByRegion;
7
+ exports.groupByRiffRaffProjectName = groupByRiffRaffProjectName;
4
8
  const array_1 = require("../utils/array");
5
9
  const types_1 = require("./types");
6
10
  function groupByClassName(cdkStacks) {
7
11
  return (0, array_1.groupBy)(cdkStacks, (stack) => stack.constructor.name);
8
12
  }
9
- exports.groupByClassName = groupByClassName;
10
13
  function groupByStackTag(cdkStacks) {
11
14
  return (0, array_1.groupBy)(cdkStacks, ({ stack }) => stack);
12
15
  }
13
- exports.groupByStackTag = groupByStackTag;
14
16
  function groupByStageTag(cdkStacks) {
15
17
  return (0, array_1.groupBy)(cdkStacks, ({ stage }) => stage);
16
18
  }
17
- exports.groupByStageTag = groupByStageTag;
18
19
  function groupByRegion(cdkStacks) {
19
20
  return (0, array_1.groupBy)(cdkStacks, ({ region }) => region);
20
21
  }
21
- exports.groupByRegion = groupByRegion;
22
22
  function groupByRiffRaffProjectName(cdkStacks) {
23
23
  return (0, array_1.groupBy)(cdkStacks, (_) => _.riffRaffProjectName ?? types_1.UnknownRiffRaffProjectName);
24
24
  }
25
- exports.groupByRiffRaffProjectName = groupByRiffRaffProjectName;
26
25
  //# sourceMappingURL=group-by.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"group-by.js","sourceRoot":"","sources":["../../src/riff-raff-yaml-file/group-by.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AAEzC,mCAAqD;AAErD,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAFD,sCAEC;AAED,SAAgB,0BAA0B,CAAC,SAAoB;IAC7D,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,IAAI,kCAA0B,CAAC,CAAC;AACxF,CAAC;AAFD,gEAEC","sourcesContent":["import type { GuStack } from \"../constructs/core\";\nimport { groupBy } from \"../utils/array\";\nimport type { ClassName, Region, RiffRaffProjectName, StackTag, StageTag } from \"./types\";\nimport { UnknownRiffRaffProjectName } from \"./types\";\n\nexport function groupByClassName(cdkStacks: GuStack[]): Record<ClassName, GuStack[]> {\n return groupBy(cdkStacks, (stack) => stack.constructor.name);\n}\n\nexport function groupByStackTag(cdkStacks: GuStack[]): Record<StackTag, GuStack[]> {\n return groupBy(cdkStacks, ({ stack }) => stack);\n}\n\nexport function groupByStageTag(cdkStacks: GuStack[]): Record<StageTag, GuStack[]> {\n return groupBy(cdkStacks, ({ stage }) => stage);\n}\n\nexport function groupByRegion(cdkStacks: GuStack[]): Record<Region, GuStack[]> {\n return groupBy(cdkStacks, ({ region }) => region);\n}\n\nexport function groupByRiffRaffProjectName(cdkStacks: GuStack[]): Record<RiffRaffProjectName, GuStack[]> {\n return groupBy(cdkStacks, (_) => _.riffRaffProjectName ?? UnknownRiffRaffProjectName);\n}\n"]}
1
+ {"version":3,"file":"group-by.js","sourceRoot":"","sources":["../../src/riff-raff-yaml-file/group-by.ts"],"names":[],"mappings":";;AAKA,4CAEC;AAED,0CAEC;AAED,0CAEC;AAED,sCAEC;AAED,gEAEC;AAtBD,0CAAyC;AAEzC,mCAAqD;AAErD,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,SAAgB,0BAA0B,CAAC,SAAoB;IAC7D,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,IAAI,kCAA0B,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { GuStack } from \"../constructs/core\";\nimport { groupBy } from \"../utils/array\";\nimport type { ClassName, Region, RiffRaffProjectName, StackTag, StageTag } from \"./types\";\nimport { UnknownRiffRaffProjectName } from \"./types\";\n\nexport function groupByClassName(cdkStacks: GuStack[]): Record<ClassName, GuStack[]> {\n return groupBy(cdkStacks, (stack) => stack.constructor.name);\n}\n\nexport function groupByStackTag(cdkStacks: GuStack[]): Record<StackTag, GuStack[]> {\n return groupBy(cdkStacks, ({ stack }) => stack);\n}\n\nexport function groupByStageTag(cdkStacks: GuStack[]): Record<StageTag, GuStack[]> {\n return groupBy(cdkStacks, ({ stage }) => stage);\n}\n\nexport function groupByRegion(cdkStacks: GuStack[]): Record<Region, GuStack[]> {\n return groupBy(cdkStacks, ({ region }) => region);\n}\n\nexport function groupByRiffRaffProjectName(cdkStacks: GuStack[]): Record<RiffRaffProjectName, GuStack[]> {\n return groupBy(cdkStacks, (_) => _.riffRaffProjectName ?? UnknownRiffRaffProjectName);\n}\n"]}
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateRiffRaffYamlDirectory = exports.RiffRaffYamlFile = void 0;
6
+ exports.RiffRaffYamlFile = void 0;
7
+ exports.validateRiffRaffYamlDirectory = validateRiffRaffYamlDirectory;
7
8
  const fs_1 = require("fs");
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const aws_cdk_lib_1 = require("aws-cdk-lib");
@@ -240,5 +241,4 @@ function validateRiffRaffYamlDirectory(basePath, riffRaffProjectName) {
240
241
  }
241
242
  return resolvedPath;
242
243
  }
243
- exports.validateRiffRaffYamlDirectory = validateRiffRaffYamlDirectory;
244
244
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/riff-raff-yaml-file/index.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA0D;AAC1D,gDAAwB;AAExB,6CAAoC;AAEpC,qCAA+B;AAC/B,2DAA+D;AAC/D,6CAA6C;AAC7C,iDAAwD;AACxD,8DAAmG;AACnG,2DAA6F;AAC7F,iEAIsC;AACtC,iDAAoF;AACpF,uEAA6E;AAC7E,yCAMoB;AAYpB,mCAAqD;AAErD,SAAS,6BAA6B,CAAC,OAAiB;IACtD,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,mBAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1E,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,8FAA8F,CAAC,CAAC;KACjH;AACH,CAAC;AAED,SAAS,UAAU,CAAC,QAAiB;IACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,yBAAgB,CAAuB,CAAC;AACpG,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAiB;IAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,gCAAkB,CAAyB,CAAC;AACxG,CAAC;AAED,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AC,KAAK,cAAI,CAAC,GAAG,EAAE,CAAC,IAAI,cAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAErH,IAAI,SAAS,EAAE;QACb,MAAM,IAAI,KAAK,CACb,kCAAkC,mBAAmB,yCAAyC,QAAQ,yBAAyB,mBAAmB,mBAAmB,YAAY,oBAAoB,YAAY,IAAI,CACtN,CAAC;KACH;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAbD,sEAaC","sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport type { App } from \"aws-cdk-lib\";\nimport { Token } from \"aws-cdk-lib\";\nimport type { CfnAutoScalingGroup } from \"aws-cdk-lib/aws-autoscaling\";\nimport { dump } from \"js-yaml\";\nimport { GuAutoScalingGroup } from \"../constructs/autoscaling\";\nimport { GuStack } from \"../constructs/core\";\nimport { GuLambdaFunction } from \"../constructs/lambda\";\nimport { GuAsgMinInstancesInServiceParameterExperimental } from \"../experimental/patterns/ec2-app\";\nimport { autoscalingDeployment, uploadAutoscalingArtifact } from \"./deployments/autoscaling\";\nimport {\n cloudFormationDeployment,\n getAmiParameters,\n getMinInstancesInServiceParameters,\n} from \"./deployments/cloudformation\";\nimport { updateLambdaDeployment, uploadLambdaArtifact } from \"./deployments/lambda\";\nimport { updateDeploymentParameters } from \"./deployments/update-parameters\";\nimport {\n groupByClassName,\n groupByRegion,\n groupByRiffRaffProjectName,\n groupByStackTag,\n groupByStageTag,\n} from \"./group-by\";\nimport type {\n ClassName,\n Region,\n RiffRaffDeployment,\n RiffRaffDeploymentName,\n RiffRaffDeploymentProps,\n RiffRaffProjectName,\n RiffRaffYaml,\n StackTag,\n StageTag,\n} from \"./types\";\nimport { UnknownRiffRaffProjectName } from \"./types\";\n\nfunction validateAllRegionsAreResolved(regions: Region[]): void {\n const unresolved = regions.filter((region) => Token.isUnresolved(region));\n\n if (unresolved.length !== 0) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; all stacks must have an explicit region set`);\n }\n}\n\nfunction getLambdas(cdkStack: GuStack): GuLambdaFunction[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuLambdaFunction) as GuLambdaFunction[];\n}\n\nfunction getAutoScalingGroups(cdkStack: GuStack): GuAutoScalingGroup[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuAutoScalingGroup) as GuAutoScalingGroup[];\n}\n\nfunction getGuStackDependencies(cdkStack: GuStack): GuStack[] {\n return cdkStack.dependencies.filter((_) => _ instanceof GuStack) as GuStack[];\n}\n\ninterface MissingStack {\n riffRaffProjectName: RiffRaffProjectName;\n className: ClassName;\n stack: StackTag;\n stage: StageTag;\n region: Region;\n}\n\n/**\n * A class that creates a `riff-raff.yaml` file.\n *\n * Rather than using this directly, prefer to use [[`GuRoot`]] instead.\n *\n * Supports:\n * - Multiple CloudFormation stacks\n * - Multiple regions\n * - Lambda applications\n * - EC2 (autoscaling) applications\n *\n * For lambda applications, 3 deployments will be defined:\n * 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Lambda update (`aws-lambda`, `action: [updateLambda]`)\n *\n * For EC2 applications, 3 deployments will be defined:\n * 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)\n *\n * It assumes a Riff-Raff bundle structure as follows:\n *\n * ```\n * .\n * ├── cdk.out\n * │ └── MyApplication.template.json\n * ├── my-application\n * │ └── my-application.deb\n * └── my-lambda\n * └── my-lambda.zip\n * ```\n *\n * That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.\n * Application artifact(s) are in the app directory.\n *\n * NOTE: The file extension is decided by you, the above file tree is used for illustration purposes.\n *\n * NOTE: Resources will be looked up by tags (Stack, Stage, App). Ensure your CFN stack is tagged appropriately!\n *\n * @see https://riffraff.gutools.co.uk/docs/reference/riff-raff.yaml.md\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\nexport class RiffRaffYamlFile {\n private readonly outdir: string;\n\n /**\n * A mapping between a Riff-Raff project and `riff-raff.yaml` content as an object.\n *\n * It is useful for specifying additional deployment types that GuCDK does not support.\n * Consider raising an issue or pull request if you think it should be supported.\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\n public readonly configuration: Map<RiffRaffProjectName, RiffRaffYaml>;\n\n // eslint-disable-next-line custom-rules/valid-constructors -- this needs to sit above GuStack on the cdk tree\n constructor(app: App) {\n const allCdkStacks = app.node.findAll().filter((_) => _ instanceof GuStack) as GuStack[];\n const allRegions = Array.from(new Set(allCdkStacks.map((_) => _.region)));\n\n validateAllRegionsAreResolved(allRegions);\n\n this.outdir = app.outdir;\n const configuration = new Map<RiffRaffProjectName, RiffRaffYaml>();\n const missingStacks: MissingStack[] = [];\n\n Object.entries(groupByRiffRaffProjectName(allCdkStacks)).forEach(\n ([riffRaffProjectName, stacksGroupedByRiffRaffProject]) => {\n const allowedStages = new Set(stacksGroupedByRiffRaffProject.map((_) => _.stage));\n const requiredStages = Array.from(allowedStages);\n const deployments = new Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>();\n\n Object.entries(groupByClassName(stacksGroupedByRiffRaffProject)).forEach(\n ([className, stacksGroupedByClassName]) => {\n Object.entries(groupByStackTag(stacksGroupedByClassName)).forEach(([stackTag, stacksGroupedByStackTag]) => {\n Object.entries(groupByRegion(stacksGroupedByStackTag)).forEach(([region, stacksGroupedByRegion]) => {\n const stacks: GuStack[] = Object.values(groupByStageTag(stacksGroupedByRegion)).flat();\n\n requiredStages.forEach((requiredStage) => {\n if (!stacks.find(({ stage }) => stage === requiredStage)) {\n missingStacks.push({\n riffRaffProjectName,\n className,\n region,\n stack: stackTag,\n stage: requiredStage,\n });\n }\n });\n\n // The items in `stacks` only differ by stage, so we can just use the first item in the list.\n const [stack] = stacks;\n\n if (!stack) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n const lambdas = getLambdas(stack);\n const autoscalingGroups = getAutoScalingGroups(stack);\n\n const artifactUploads: RiffRaffDeployment[] = [\n lambdas.filter((_) => !_.withoutArtifactUpload).map(uploadLambdaArtifact),\n autoscalingGroups.map(uploadAutoscalingArtifact),\n ].flat();\n artifactUploads.forEach(({ name, props }) => deployments.set(name, props));\n\n const parentStacks: RiffRaffDeployment[] = getGuStackDependencies(stack).map((x) =>\n cloudFormationDeployment([x], [], this.outdir),\n );\n\n const cfnDeployment = cloudFormationDeployment(\n stacks,\n [...artifactUploads, ...parentStacks],\n this.outdir,\n );\n deployments.set(cfnDeployment.name, cfnDeployment.props);\n\n const lambdasWithoutAnAlias = lambdas.filter((lambda) => lambda.alias === undefined);\n // If the Lambda has an alias it is using versioning. When using versioning, there is no need for Riff-Raff\n // to modify the unpublished version of the function\n lambdasWithoutAnAlias.forEach((lambda) => {\n const lambdaDeployment = updateLambdaDeployment(lambda, cfnDeployment);\n deployments.set(lambdaDeployment.name, lambdaDeployment.props);\n });\n\n /*\n Instances in an ASG with an `AutoScalingRollingUpdate` update policy are rotated via CloudFormation.\n Therefore, they do not need to also perform an `autoscaling` deployment via Riff-Raff.\n */\n const legacyAutoscalingGroups = autoscalingGroups.filter((asg) => {\n const { cfnOptions } = asg.node.defaultChild as CfnAutoScalingGroup;\n const { updatePolicy } = cfnOptions;\n return updatePolicy?.autoScalingRollingUpdate === undefined;\n });\n\n legacyAutoscalingGroups.forEach((asg) => {\n const asgDeployment = autoscalingDeployment(asg, cfnDeployment);\n deployments.set(asgDeployment.name, asgDeployment.props);\n });\n\n // only add the `amiParametersToTags` property if there are some ASGs in the stack\n if (autoscalingGroups.length > 0) {\n updateDeploymentParameters(deployments, cfnDeployment, {\n amiParametersToTags: getAmiParameters(autoscalingGroups),\n });\n }\n\n /*\n At this point, `stacks` is a collection of similar `GuStack`s that differ only by their `stage`.\n We're about to add `minInstancesInServiceParameters` to assist Riff-Raff when deploying ASGs with scaling policies.\n This is driven by the presence of conditionally added CFN Parameters.\n To support the possibility of there being a scaling policy in PROD but not CODE, look at all the CFN Parameters in `stacks`.\n */\n const minInstancesInServiceParameters: Map<string, GuAsgMinInstancesInServiceParameterExperimental> =\n stacks\n .flatMap((stack) => Object.values(stack.parameters))\n .filter(\n (_): _ is GuAsgMinInstancesInServiceParameterExperimental =>\n _ instanceof GuAsgMinInstancesInServiceParameterExperimental,\n )\n .reduce((acc, item) => {\n if (!acc.has(item.node.id)) {\n acc.set(item.node.id, item);\n }\n return acc;\n }, new Map<string, GuAsgMinInstancesInServiceParameterExperimental>());\n\n /**\n * Only add the `minInstancesInServiceParameters` property if there are some ASGs affected by {@link GuHorizontallyScalingDeploymentPropertiesExperimental}.\n */\n if (minInstancesInServiceParameters.size > 0) {\n updateDeploymentParameters(deployments, cfnDeployment, {\n minInstancesInServiceParameters: getMinInstancesInServiceParameters(\n minInstancesInServiceParameters,\n ),\n });\n }\n });\n });\n },\n );\n\n configuration.set(riffRaffProjectName, { allowedStages, deployments });\n },\n );\n\n if (missingStacks.length > 0) {\n const message = `Unable to produce a working riff-raff.yaml file; missing ${missingStacks.length} definitions`;\n console.log(`${message} (details below)`);\n console.table(missingStacks);\n\n throw new Error(message);\n }\n\n this.configuration = configuration;\n }\n\n /**\n * A `riff-raff.yaml` file as a string.\n * Useful for testing.\n *\n * @param riffRaffProjectName which project to convert to YAML. Defaults to {@link UnknownRiffRaffProjectName} - any {@link GuStack} without an explicit `riffRaffProjectName` property.\n */\n toYAML(riffRaffProjectName: RiffRaffProjectName = UnknownRiffRaffProjectName): string {\n // Add support for ES6 Set and Map. See https://github.com/nodeca/js-yaml/issues/436.\n const replacer = (_key: string, value: unknown) => {\n if (value instanceof Set) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Array.from(value);\n }\n if (value instanceof Map) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Object.fromEntries(value);\n }\n return value;\n };\n\n const content = this.configuration.get(riffRaffProjectName);\n\n if (!content) {\n throw new Error(`No Riff-Raff project found with name: ${riffRaffProjectName}`);\n }\n\n const yaml = dump(content, { replacer });\n\n const comments = [\n \"This file was generated by @guardian/cdk, do not edit it directly.\",\n \"See also https://github.com/guardian/cdk/blob/main/src/riff-raff-yaml-file/README.md.\",\n ]\n .map((line) => `# ${line}`)\n .join(\"\\n\");\n\n return [comments, yaml].join(\"\\n\");\n }\n\n /**\n * Write the `riff-raff.yaml` file(s) to disk, located in the same directory as the CFN JSON templates generated by `cdk synth`.\n */\n synth(): void {\n this.configuration.forEach((_, riffRaffProjectName) => {\n const targetDirectory =\n riffRaffProjectName === UnknownRiffRaffProjectName\n ? this.outdir\n : validateRiffRaffYamlDirectory(this.outdir, riffRaffProjectName);\n\n if (!existsSync(targetDirectory)) {\n mkdirSync(targetDirectory, { recursive: true });\n }\n\n const outPath = path.join(targetDirectory, \"riff-raff.yaml\");\n writeFileSync(outPath, this.toYAML(riffRaffProjectName));\n });\n }\n}\n\nexport function validateRiffRaffYamlDirectory(basePath: string, riffRaffProjectName: RiffRaffProjectName): string {\n const resolvedBase = path.resolve(basePath);\n const resolvedPath = path.resolve(basePath, riffRaffProjectName);\n const relativePath = path.relative(resolvedBase, resolvedPath);\n const isOutside = relativePath === \"..\" || relativePath.startsWith(`..${path.sep}`) || path.isAbsolute(relativePath);\n\n if (isOutside) {\n throw new Error(\n `Directory traversal detected: '${riffRaffProjectName}' would create a directory outside of ${basePath} (riffRaffProjectName=${riffRaffProjectName}, resolvedPath='${resolvedPath}', resolvedBase='${resolvedBase}')`,\n );\n }\n\n return resolvedPath;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/riff-raff-yaml-file/index.ts"],"names":[],"mappings":";;;;;;AAkUA,sEAaC;AA/UD,2BAA0D;AAC1D,gDAAwB;AAExB,6CAAoC;AAEpC,qCAA+B;AAC/B,2DAA+D;AAC/D,6CAA6C;AAC7C,iDA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-cdk-lib\";\nimport { Token } from \"aws-cdk-lib\";\nimport type { CfnAutoScalingGroup } from \"aws-cdk-lib/aws-autoscaling\";\nimport { dump } from \"js-yaml\";\nimport { GuAutoScalingGroup } from \"../constructs/autoscaling\";\nimport { GuStack } from \"../constructs/core\";\nimport { GuLambdaFunction } from \"../constructs/lambda\";\nimport { GuAsgMinInstancesInServiceParameterExperimental } from \"../experimental/patterns/ec2-app\";\nimport { autoscalingDeployment, uploadAutoscalingArtifact } from \"./deployments/autoscaling\";\nimport {\n cloudFormationDeployment,\n getAmiParameters,\n getMinInstancesInServiceParameters,\n} from \"./deployments/cloudformation\";\nimport { updateLambdaDeployment, uploadLambdaArtifact } from \"./deployments/lambda\";\nimport { updateDeploymentParameters } from \"./deployments/update-parameters\";\nimport {\n groupByClassName,\n groupByRegion,\n groupByRiffRaffProjectName,\n groupByStackTag,\n groupByStageTag,\n} from \"./group-by\";\nimport type {\n ClassName,\n Region,\n RiffRaffDeployment,\n RiffRaffDeploymentName,\n RiffRaffDeploymentProps,\n RiffRaffProjectName,\n RiffRaffYaml,\n StackTag,\n StageTag,\n} from \"./types\";\nimport { UnknownRiffRaffProjectName } from \"./types\";\n\nfunction validateAllRegionsAreResolved(regions: Region[]): void {\n const unresolved = regions.filter((region) => Token.isUnresolved(region));\n\n if (unresolved.length !== 0) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; all stacks must have an explicit region set`);\n }\n}\n\nfunction getLambdas(cdkStack: GuStack): GuLambdaFunction[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuLambdaFunction);\n}\n\nfunction getAutoScalingGroups(cdkStack: GuStack): GuAutoScalingGroup[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuAutoScalingGroup);\n}\n\nfunction getGuStackDependencies(cdkStack: GuStack): GuStack[] {\n return cdkStack.dependencies.filter((_) => _ instanceof GuStack);\n}\n\ninterface MissingStack {\n riffRaffProjectName: RiffRaffProjectName;\n className: ClassName;\n stack: StackTag;\n stage: StageTag;\n region: Region;\n}\n\n/**\n * A class that creates a `riff-raff.yaml` file.\n *\n * Rather than using this directly, prefer to use [[`GuRoot`]] instead.\n *\n * Supports:\n * - Multiple CloudFormation stacks\n * - Multiple regions\n * - Lambda applications\n * - EC2 (autoscaling) applications\n *\n * For lambda applications, 3 deployments will be defined:\n * 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Lambda update (`aws-lambda`, `action: [updateLambda]`)\n *\n * For EC2 applications, 3 deployments will be defined:\n * 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)\n *\n * It assumes a Riff-Raff bundle structure as follows:\n *\n * ```\n * .\n * ├── cdk.out\n * │ └── MyApplication.template.json\n * ├── my-application\n * │ └── my-application.deb\n * └── my-lambda\n * └── my-lambda.zip\n * ```\n *\n * That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.\n * Application artifact(s) are in the app directory.\n *\n * NOTE: The file extension is decided by you, the above file tree is used for illustration purposes.\n *\n * NOTE: Resources will be looked up by tags (Stack, Stage, App). Ensure your CFN stack is tagged appropriately!\n *\n * @see https://riffraff.gutools.co.uk/docs/reference/riff-raff.yaml.md\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\nexport class RiffRaffYamlFile {\n private readonly outdir: string;\n\n /**\n * A mapping between a Riff-Raff project and `riff-raff.yaml` content as an object.\n *\n * It is useful for specifying additional deployment types that GuCDK does not support.\n * Consider raising an issue or pull request if you think it should be supported.\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\n public readonly configuration: Map<RiffRaffProjectName, RiffRaffYaml>;\n\n // eslint-disable-next-line custom-rules/valid-constructors -- this needs to sit above GuStack on the cdk tree\n constructor(app: App) {\n const allCdkStacks = app.node.findAll().filter((_) => _ instanceof GuStack);\n const allRegions = Array.from(new Set(allCdkStacks.map((_) => _.region)));\n\n validateAllRegionsAreResolved(allRegions);\n\n this.outdir = app.outdir;\n const configuration = new Map<RiffRaffProjectName, RiffRaffYaml>();\n const missingStacks: MissingStack[] = [];\n\n Object.entries(groupByRiffRaffProjectName(allCdkStacks)).forEach(\n ([riffRaffProjectName, stacksGroupedByRiffRaffProject]) => {\n const allowedStages = new Set(stacksGroupedByRiffRaffProject.map((_) => _.stage));\n const requiredStages = Array.from(allowedStages);\n const deployments = new Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>();\n\n Object.entries(groupByClassName(stacksGroupedByRiffRaffProject)).forEach(\n ([className, stacksGroupedByClassName]) => {\n Object.entries(groupByStackTag(stacksGroupedByClassName)).forEach(([stackTag, stacksGroupedByStackTag]) => {\n Object.entries(groupByRegion(stacksGroupedByStackTag)).forEach(([region, stacksGroupedByRegion]) => {\n const stacks: GuStack[] = Object.values(groupByStageTag(stacksGroupedByRegion)).flat();\n\n requiredStages.forEach((requiredStage) => {\n if (!stacks.find(({ stage }) => stage === requiredStage)) {\n missingStacks.push({\n riffRaffProjectName,\n className,\n region,\n stack: stackTag,\n stage: requiredStage,\n });\n }\n });\n\n // The items in `stacks` only differ by stage, so we can just use the first item in the list.\n const [stack] = stacks;\n\n if (!stack) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n const lambdas = getLambdas(stack);\n const autoscalingGroups = getAutoScalingGroups(stack);\n\n const artifactUploads: RiffRaffDeployment[] = [\n lambdas.filter((_) => !_.withoutArtifactUpload).map(uploadLambdaArtifact),\n autoscalingGroups.map(uploadAutoscalingArtifact),\n ].flat();\n artifactUploads.forEach(({ name, props }) => deployments.set(name, props));\n\n const parentStacks: RiffRaffDeployment[] = getGuStackDependencies(stack).map((x) =>\n cloudFormationDeployment([x], [], this.outdir),\n );\n\n const cfnDeployment = cloudFormationDeployment(\n stacks,\n [...artifactUploads, ...parentStacks],\n this.outdir,\n );\n deployments.set(cfnDeployment.name, cfnDeployment.props);\n\n const lambdasWithoutAnAlias = lambdas.filter((lambda) => lambda.alias === undefined);\n // If the Lambda has an alias it is using versioning. When using versioning, there is no need for Riff-Raff\n // to modify the unpublished version of the function\n lambdasWithoutAnAlias.forEach((lambda) => {\n const lambdaDeployment = updateLambdaDeployment(lambda, cfnDeployment);\n deployments.set(lambdaDeployment.name, lambdaDeployment.props);\n });\n\n /*\n Instances in an ASG with an `AutoScalingRollingUpdate` update policy are rotated via CloudFormation.\n Therefore, they do not need to also perform an `autoscaling` deployment via Riff-Raff.\n */\n const legacyAutoscalingGroups = autoscalingGroups.filter((asg) => {\n const { cfnOptions } = asg.node.defaultChild as CfnAutoScalingGroup;\n const { updatePolicy } = cfnOptions;\n return updatePolicy?.autoScalingRollingUpdate === undefined;\n });\n\n legacyAutoscalingGroups.forEach((asg) => {\n const asgDeployment = autoscalingDeployment(asg, cfnDeployment);\n deployments.set(asgDeployment.name, asgDeployment.props);\n });\n\n // only add the `amiParametersToTags` property if there are some ASGs in the stack\n if (autoscalingGroups.length > 0) {\n updateDeploymentParameters(deployments, cfnDeployment, {\n amiParametersToTags: getAmiParameters(autoscalingGroups),\n });\n }\n\n /*\n At this point, `stacks` is a collection of similar `GuStack`s that differ only by their `stage`.\n We're about to add `minInstancesInServiceParameters` to assist Riff-Raff when deploying ASGs with scaling policies.\n This is driven by the presence of conditionally added CFN Parameters.\n To support the possibility of there being a scaling policy in PROD but not CODE, look at all the CFN Parameters in `stacks`.\n */\n const minInstancesInServiceParameters: Map<string, GuAsgMinInstancesInServiceParameterExperimental> =\n stacks\n .flatMap((stack) => Object.values(stack.parameters))\n .filter(\n (_): _ is GuAsgMinInstancesInServiceParameterExperimental =>\n _ instanceof GuAsgMinInstancesInServiceParameterExperimental,\n )\n .reduce((acc, item) => {\n if (!acc.has(item.node.id)) {\n acc.set(item.node.id, item);\n }\n return acc;\n }, new Map<string, GuAsgMinInstancesInServiceParameterExperimental>());\n\n /**\n * Only add the `minInstancesInServiceParameters` property if there are some ASGs affected by {@link GuHorizontallyScalingDeploymentPropertiesExperimental}.\n */\n if (minInstancesInServiceParameters.size > 0) {\n updateDeploymentParameters(deployments, cfnDeployment, {\n minInstancesInServiceParameters: getMinInstancesInServiceParameters(\n minInstancesInServiceParameters,\n ),\n });\n }\n });\n });\n },\n );\n\n configuration.set(riffRaffProjectName, { allowedStages, deployments });\n },\n );\n\n if (missingStacks.length > 0) {\n const message = `Unable to produce a working riff-raff.yaml file; missing ${missingStacks.length} definitions`;\n console.log(`${message} (details below)`);\n console.table(missingStacks);\n\n throw new Error(message);\n }\n\n this.configuration = configuration;\n }\n\n /**\n * A `riff-raff.yaml` file as a string.\n * Useful for testing.\n *\n * @param riffRaffProjectName which project to convert to YAML. Defaults to {@link UnknownRiffRaffProjectName} - any {@link GuStack} without an explicit `riffRaffProjectName` property.\n */\n toYAML(riffRaffProjectName: RiffRaffProjectName = UnknownRiffRaffProjectName): string {\n // Add support for ES6 Set and Map. See https://github.com/nodeca/js-yaml/issues/436.\n const replacer = (_key: string, value: unknown) => {\n if (value instanceof Set) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Array.from(value);\n }\n if (value instanceof Map) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Object.fromEntries(value);\n }\n return value;\n };\n\n const content = this.configuration.get(riffRaffProjectName);\n\n if (!content) {\n throw new Error(`No Riff-Raff project found with name: ${riffRaffProjectName}`);\n }\n\n const yaml = dump(content, { replacer });\n\n const comments = [\n \"This file was generated by @guardian/cdk, do not edit it directly.\",\n \"See also https://github.com/guardian/cdk/blob/main/src/riff-raff-yaml-file/README.md.\",\n ]\n .map((line) => `# ${line}`)\n .join(\"\\n\");\n\n return [comments, yaml].join(\"\\n\");\n }\n\n /**\n * Write the `riff-raff.yaml` file(s) to disk, located in the same directory as the CFN JSON templates generated by `cdk synth`.\n */\n synth(): void {\n this.configuration.forEach((_, riffRaffProjectName) => {\n const targetDirectory =\n riffRaffProjectName === UnknownRiffRaffProjectName\n ? this.outdir\n : validateRiffRaffYamlDirectory(this.outdir, riffRaffProjectName);\n\n if (!existsSync(targetDirectory)) {\n mkdirSync(targetDirectory, { recursive: true });\n }\n\n const outPath = path.join(targetDirectory, \"riff-raff.yaml\");\n writeFileSync(outPath, this.toYAML(riffRaffProjectName));\n });\n }\n}\n\nexport function validateRiffRaffYamlDirectory(basePath: string, riffRaffProjectName: RiffRaffProjectName): string {\n const resolvedBase = path.resolve(basePath);\n const resolvedPath = path.resolve(basePath, riffRaffProjectName);\n const relativePath = path.relative(resolvedBase, resolvedPath);\n const isOutside = relativePath === \"..\" || relativePath.startsWith(`..${path.sep}`) || path.isAbsolute(relativePath);\n\n if (isOutside) {\n throw new Error(\n `Directory traversal detected: '${riffRaffProjectName}' would create a directory outside of ${basePath} (riffRaffProjectName=${riffRaffProjectName}, resolvedPath='${resolvedPath}', resolvedBase='${resolvedBase}')`,\n );\n }\n\n return resolvedPath;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/types/access.ts"],"names":[],"mappings":";;;AACA,iDAA2C;AAC3C,4CAA2C;AA0D9B,QAAA,SAAS,GAAG;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,MAAiB,EAAE,EAAE;QAC9B,QAAQ,MAAM,CAAC,KAAK,EAAE;YACpB,KAAK,uBAAW,CAAC,UAAU,CAAC,CAAC;gBAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACxD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEvC,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE;oBACxF,MAAM,IAAI,KAAK,CACb,GAAG,uBAAW,CAAC,UAAU,4DAA4D,YAAY,YAAY,uBAAW,CAAC,MAAM,GAAG,CACnI,CAAC;iBACH;gBACD,MAAM;aACP;YAED,KAAK,uBAAW,CAAC,QAAQ,CAAC,CAAC;gBACzB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACxD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEvC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE;oBACpD,MAAM,IAAI,KAAK,CACb,GAAG,uBAAW,CAAC,QAAQ,sEAAsE,YAAY,YAAY,uBAAW,CAAC,UAAU,GAAG,CAC/I,CAAC;iBACH;gBACD,MAAM;aACP;YACD;gBACE,MAAM;SACT;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { IPeer } from \"aws-cdk-lib/aws-ec2\";\nimport { Peer } from \"aws-cdk-lib/aws-ec2\";\nimport { AccessScope } from \"../constants\";\n\nexport interface Access {\n scope: AccessScope;\n}\n\n/**\n * For when you want your application to be accessible to the world (0.0.0.0/0).\n * Your application load balancer will have a public IP address that can be reached by anyone,\n * so only use if you are aware and happy with the consequences!\n *\n * Example usage:\n * ```typescript\n * { scope: AccessScope.PUBLIC }\n * ```\n */\nexport interface PublicAccess extends Access {\n scope: AccessScope.PUBLIC;\n}\n\n/**\n * For when you want to restrict your application's access to a list of CIDR ranges. For example,\n * if you want limit access to users connecting from Guardian offices only.\n *\n * Example usage:\n * ```typescript\n * {\n * scope: AccessScope.RESTRICTED,\n * cidrRanges: [Peer.ipv4(\"192.168.1.1/32\"), Peer.ipv4(\"8.8.8.8/32\")]\n * }\n * ```\n */\nexport interface RestrictedAccess extends Access {\n scope: AccessScope.RESTRICTED;\n cidrRanges: IPeer[];\n}\n\n/**\n * For when you want to restrict your application's access to services running inside your VPC.\n *\n * Note that if your account uses Direct Connect or VPC Peering, then incoming traffic from these sources\n * can also be allowed.\n *\n * Example usage:\n * ```typescript\n * {\n * scope: AccessScope.INTERNAL,\n * cidrRanges: [Peer.ipv4(\"10.0.0.0/8\")]\n * }\n * ```\n */\nexport interface InternalAccess extends Access {\n scope: AccessScope.INTERNAL;\n cidrRanges: IPeer[];\n}\n\nexport type AppAccess = PublicAccess | RestrictedAccess | InternalAccess;\n\nexport const AppAccess = {\n /**\n * Validate the CIDR rules for AppAccess.\n *\n * Public - always valid. No CIDR rules are needed here, and the type-system enforces this\n * Restricted - Must not include global CIDR ranges as doing so makes other listed CIDR ranges redundant\n * Internal - All CIDR ranges must start `10.`\n *\n * @throws `Error` when CIDR rules are invalid\n */\n validate: (access: AppAccess) => {\n switch (access.scope) {\n case AccessScope.RESTRICTED: {\n const ranges = access.cidrRanges.map((_) => _.uniqueId);\n const rangesString = ranges.join(\", \");\n\n if (ranges.includes(Peer.anyIpv4().uniqueId) || ranges.includes(Peer.anyIpv6().uniqueId)) {\n throw new Error(\n `${AccessScope.RESTRICTED} apps cannot be globally accessible. Adjust CIDR ranges (${rangesString}) or use ${AccessScope.PUBLIC}.`,\n );\n }\n break;\n }\n\n case AccessScope.INTERNAL: {\n const ranges = access.cidrRanges.map((_) => _.uniqueId);\n const rangesString = ranges.join(\", \");\n\n if (ranges.some((range) => !range.startsWith(\"10.\"))) {\n throw new Error(\n `${AccessScope.INTERNAL} apps should only be accessible on 10. ranges. Adjust CIDR ranges (${rangesString}) or use ${AccessScope.RESTRICTED}.`,\n );\n }\n break;\n }\n default:\n break;\n }\n },\n};\n"]}
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/types/access.ts"],"names":[],"mappings":";;;AACA,iDAA2C;AAC3C,4CAA2C;AA0D9B,QAAA,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,CAAC;CACF,CAAC","sourcesContent":["import type { IPeer } from \"aws-cdk-lib/aws-ec2\";\nimport { Peer } from \"aws-cdk-lib/aws-ec2\";\nimport { AccessScope } from \"../constants\";\n\nexport interface Access {\n scope: AccessScope;\n}\n\n/**\n * For when you want your application to be accessible to the world (0.0.0.0/0).\n * Your application load balancer will have a public IP address that can be reached by anyone,\n * so only use if you are aware and happy with the consequences!\n *\n * Example usage:\n * ```typescript\n * { scope: AccessScope.PUBLIC }\n * ```\n */\nexport interface PublicAccess extends Access {\n scope: AccessScope.PUBLIC;\n}\n\n/**\n * For when you want to restrict your application's access to a list of CIDR ranges. For example,\n * if you want limit access to users connecting from Guardian offices only.\n *\n * Example usage:\n * ```typescript\n * {\n * scope: AccessScope.RESTRICTED,\n * cidrRanges: [Peer.ipv4(\"192.168.1.1/32\"), Peer.ipv4(\"8.8.8.8/32\")]\n * }\n * ```\n */\nexport interface RestrictedAccess extends Access {\n scope: AccessScope.RESTRICTED;\n cidrRanges: IPeer[];\n}\n\n/**\n * For when you want to restrict your application's access to services running inside your VPC.\n *\n * Note that if your account uses Direct Connect or VPC Peering, then incoming traffic from these sources\n * can also be allowed.\n *\n * Example usage:\n * ```typescript\n * {\n * scope: AccessScope.INTERNAL,\n * cidrRanges: [Peer.ipv4(\"10.0.0.0/8\")]\n * }\n * ```\n */\nexport interface InternalAccess extends Access {\n scope: AccessScope.INTERNAL;\n cidrRanges: IPeer[];\n}\n\nexport type AppAccess = PublicAccess | RestrictedAccess | InternalAccess;\n\nexport const AppAccess = {\n /**\n * Validate the CIDR rules for AppAccess.\n *\n * Public - always valid. No CIDR rules are needed here, and the type-system enforces this\n * Restricted - Must not include global CIDR ranges as doing so makes other listed CIDR ranges redundant\n * Internal - All CIDR ranges must start `10.`\n *\n * @throws `Error` when CIDR rules are invalid\n */\n validate: (access: AppAccess) => {\n switch (access.scope) {\n case AccessScope.RESTRICTED: {\n const ranges = access.cidrRanges.map((_) => _.uniqueId);\n const rangesString = ranges.join(\", \");\n\n if (ranges.includes(Peer.anyIpv4().uniqueId) || ranges.includes(Peer.anyIpv6().uniqueId)) {\n throw new Error(\n `${AccessScope.RESTRICTED} apps cannot be globally accessible. Adjust CIDR ranges (${rangesString}) or use ${AccessScope.PUBLIC}.`,\n );\n }\n break;\n }\n\n case AccessScope.INTERNAL: {\n const ranges = access.cidrRanges.map((_) => _.uniqueId);\n const rangesString = ranges.join(\", \");\n\n if (ranges.some((range) => !range.startsWith(\"10.\"))) {\n throw new Error(\n `${AccessScope.INTERNAL} apps should only be accessible on 10. ranges. Adjust CIDR ranges (${rangesString}) or use ${AccessScope.RESTRICTED}.`,\n );\n }\n break;\n }\n default:\n break;\n }\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupBy = void 0;
3
+ exports.groupBy = groupBy;
4
4
  /**
5
5
  * Group an array of T by a field in T.
6
6
  * @param input what to group
@@ -16,5 +16,4 @@ function groupBy(input, keyFn) {
16
16
  };
17
17
  }, {});
18
18
  }
19
- exports.groupBy = groupBy;
20
19
  //# sourceMappingURL=array.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,OAAO,CAAI,KAAU,EAAE,KAAuB;IAC5D,OAAO,KAAK,CAAC,MAAM,CAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACxD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO;YACL,GAAG,GAAG;YACN,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC;SAC7B,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AATD,0BASC","sourcesContent":["/**\n * Group an array of T by a field in T.\n * @param input what to group\n * @param keyFn which field to group on\n */\nexport function groupBy<T>(input: T[], keyFn: (i: T) => string): Record<string, T[]> {\n return input.reduce<Record<string, T[]>>((acc, element) => {\n const key = keyFn(element);\n const current = acc[key] ?? [];\n return {\n ...acc,\n [key]: [...current, element],\n };\n }, {});\n}\n"]}
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":";;AAKA,0BASC;AAdD;;;;GAIG;AACH,SAAgB,OAAO,CAAI,KAAU,EAAE,KAAuB;IAC5D,OAAO,KAAK,CAAC,MAAM,CAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACxD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO;YACL,GAAG,GAAG;YACN,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC;SAC7B,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["/**\n * Group an array of T by a field in T.\n * @param input what to group\n * @param keyFn which field to group on\n */\nexport function groupBy<T>(input: T[], keyFn: (i: T) => string): Record<string, T[]> {\n return input.reduce<Record<string, T[]>>((acc, element) => {\n const key = keyFn(element);\n const current = acc[key] ?? [];\n return {\n ...acc,\n [key]: [...current, element],\n };\n }, {});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"vpc.d.ts","sourceRoot":"","sources":["../../../src/utils/cli/vpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,GAAG,EAAe,MAAM,qBAAqB,CAAC;AACvG,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAE/C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAGvC,CAAC;AAWH,eAAO,MAAM,sBAAsB,cAAqB,GAAG,KAAG,QAAQ,SAAS,EAAE,CAWhF,CAAC;AA2CF,eAAO,MAAM,eAAe,cAAqB,GAAG,KAAG,QAAQ,WAAW,EAAE,CAgB3E,CAAC"}
1
+ {"version":3,"file":"vpc.d.ts","sourceRoot":"","sources":["../../../src/utils/cli/vpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,GAAG,EAAe,MAAM,qBAAqB,CAAC;AACvG,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAE/C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAGvC,CAAC;AAWH,eAAO,MAAM,sBAAsB,GAAU,WAAW,GAAG,KAAG,OAAO,CAAC,SAAS,EAAE,CAWhF,CAAC;AA2CF,eAAO,MAAM,eAAe,GAAU,WAAW,GAAG,KAAG,OAAO,CAAC,WAAW,EAAE,CAgB3E,CAAC"}