@fjall/components-infrastructure 40.0.4 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/config/aws/scpPreset.d.ts +9 -1
- package/dist/lib/config/aws/scpPreset.js +56 -2
- package/dist/lib/lambda-assets/ci-oidc-provider/asset/THIRD-PARTY-NOTICES.txt +1302 -0
- package/dist/lib/lambda-assets/ci-oidc-provider/asset/index.js +47 -0
- package/dist/lib/lambda-assets/ci-oidc-provider/asset/package.json +4 -0
- package/dist/lib/patterns/aws/buildkite/image/components/ciNode.d.ts +7 -5
- package/dist/lib/patterns/aws/buildkite/image/components/ciNode.js +7 -5
- package/dist/lib/patterns/aws/cdn.d.ts +12 -1
- package/dist/lib/patterns/aws/cdn.js +25 -55
- package/dist/lib/patterns/aws/interfaces/pattern.d.ts +12 -0
- package/dist/lib/patterns/aws/organisation.d.ts +7 -2
- package/dist/lib/patterns/aws/organisation.js +6 -2
- package/dist/lib/patterns/aws/redirectHosts.d.ts +24 -0
- package/dist/lib/patterns/aws/redirectHosts.js +48 -0
- package/dist/lib/patterns/aws/staticSite.d.ts +1 -0
- package/dist/lib/patterns/aws/staticSite.js +52 -18
- package/dist/lib/resources/aws/cdn/cloudFront.d.ts +4 -1
- package/dist/lib/resources/aws/cdn/cloudFront.js +8 -2
- package/dist/lib/resources/aws/cdn/cloudFrontHostRedirect.d.ts +6 -6
- package/dist/lib/resources/aws/cdn/cloudFrontHostRedirect.js +6 -6
- package/dist/lib/resources/aws/iam/oidcProviderAdoption.d.ts +2 -2
- package/dist/lib/resources/aws/iam/oidcProviderAdoption.js +12 -6
- package/dist/lib/terminology/parity/storageAndNetworking.js +2 -0
- package/dist/lib/utils/orgConfigParser.d.ts +2 -2
- package/dist/lib/utils/orgConfigParser.js +2 -2
- package/package.json +5 -4
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
export interface ScpPresetProps {
|
|
3
3
|
rootId: string;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The regions member accounts may use. Unset, it is the regions the
|
|
6
|
+
* organisation deploys to (`organisationDeployRegions`) from the org config
|
|
7
|
+
* Fjall passes at synth, plus us-east-1, so with no primary region set it
|
|
8
|
+
* allows the region the cascade deploys as. Unset with an org config that
|
|
9
|
+
* names only blank regions, it is the list 40.1.0 rendered, with a warning.
|
|
10
|
+
* Unset with one that names no region at all, the synth is refused.
|
|
11
|
+
*/
|
|
12
|
+
allowedRegions?: string[];
|
|
5
13
|
}
|
|
6
14
|
/**
|
|
7
15
|
* Attaches the 3 root Service Control Policies (FoundationGuardrails,
|
|
@@ -1,11 +1,65 @@
|
|
|
1
1
|
import { CDK_EXEC_ROLE_ARN_PATTERN, DEPLOY_ROLE_ARN_PATTERN, anyPartitionArnPattern } from "@fjall/generator";
|
|
2
|
-
import { COST_CONTROL_CLASSES, removedPropsOf } from "@fjall/util";
|
|
2
|
+
import { CDK_CONTEXT_KEYS, COST_CONTROL_CLASSES, DEFAULT_REGION, cascadePrimaryRegion, deriveRegionsFromOrgConfig, isAnyPartitionRegionCodeShape, organisationDeployRegions, removedPropsOf } from "@fjall/util";
|
|
3
3
|
import { OPERATOR_TAG_KEY_PATTERN } from "@fjall/util/aws";
|
|
4
|
+
import { Annotations } from "aws-cdk-lib";
|
|
4
5
|
import { Construct } from "constructs";
|
|
5
6
|
import { DELEGATION_ROLE_NAME_SUFFIX } from "../../resources/aws/iam/delegationRole.js";
|
|
6
7
|
import { OrganisationPolicy } from "../../resources/aws/organisation/organisationPolicy.js";
|
|
7
8
|
import { refuseRemovedProps } from "../../terminology/refuseRemoved.js";
|
|
9
|
+
import { parseOrgConfig } from "../../utils/orgConfigParser.js";
|
|
8
10
|
import { S3_BPA_MANAGER_ROLE_NAME, S3_BPA_MANAGER_ROLE_PATH } from "./s3BlockPublicAccess.js";
|
|
11
|
+
const US_EAST_1 = "us-east-1";
|
|
12
|
+
const LIST_THE_REGIONS = `list the organisation's primary region (${DEFAULT_REGION} while it sets none), its secondary and disaster recovery regions, and us-east-1`;
|
|
13
|
+
/**
|
|
14
|
+
* An empty list makes DenyOutsideAllowedRegions deny every action outside its
|
|
15
|
+
* exemptions in every member account (inferred, not seen live), and an entry
|
|
16
|
+
* not shaped like a region code can never allow the region it was meant to
|
|
17
|
+
* name. The check reads the shape only, so a misspelt code such as eu-wset-1
|
|
18
|
+
* passes it. A minor release keeps the list the operator wrote, so both render
|
|
19
|
+
* as given and warn. 41.0.0 refuses them.
|
|
20
|
+
*/
|
|
21
|
+
function resolveAllowedRegions(scope, allowedRegions) {
|
|
22
|
+
if (allowedRegions === undefined) {
|
|
23
|
+
const orgConfig = parseOrgConfig(scope.node.tryGetContext(CDK_CONTEXT_KEYS.ORG_CONFIG));
|
|
24
|
+
if (deriveRegionsFromOrgConfig(orgConfig).length === 0) {
|
|
25
|
+
// 40.1.0 read a region of only whitespace as set, so for an org config
|
|
26
|
+
// naming only blank regions a 40.x release renders 40.1.0's list.
|
|
27
|
+
const { primaryRegion } = orgConfig;
|
|
28
|
+
const blank = [
|
|
29
|
+
primaryRegion,
|
|
30
|
+
...orgConfig.secondaryRegions,
|
|
31
|
+
orgConfig.disasterRecoveryRegion
|
|
32
|
+
].filter((region) => region !== undefined && region !== "");
|
|
33
|
+
if (blank.length === 0) {
|
|
34
|
+
throw new Error(`ScpPreset has no allowedRegions and the org config names no region, so it cannot tell which regions member accounts may use. Deploy through Fjall with the organisation's regions named in its org config, or ${LIST_THE_REGIONS} in allowedRegions in the organisation's infrastructure.ts.`);
|
|
35
|
+
}
|
|
36
|
+
const deploysAs = primaryRegion === undefined || primaryRegion === ""
|
|
37
|
+
? [cascadePrimaryRegion(orgConfig)]
|
|
38
|
+
: [];
|
|
39
|
+
const allows = [...new Set([...deploysAs, US_EAST_1])].join(" and ");
|
|
40
|
+
Annotations.of(scope).addWarningV2("fjall:scp-preset:blank-org-regions", `ScpPreset has no allowedRegions and the org config names only blank regions, so it renders the list 40.1.0 rendered. A blank region matches no request, so the regions it allows are ${allows}. Name the organisation's regions in its org config and leave the blank ones out, or ${LIST_THE_REGIONS} in allowedRegions in the organisation's infrastructure.ts. 41.0.0 leaves the blank regions out, so it allows ${DEFAULT_REGION} and ${US_EAST_1}.`);
|
|
41
|
+
return [...new Set([...deploysAs, ...blank, US_EAST_1])];
|
|
42
|
+
}
|
|
43
|
+
return [...new Set([...organisationDeployRegions(orgConfig), US_EAST_1])];
|
|
44
|
+
}
|
|
45
|
+
// tsx never typechecks infrastructure.ts, and 40.0.4 rendered a lone string
|
|
46
|
+
// as a one value condition, so it still renders as given.
|
|
47
|
+
const given = allowedRegions;
|
|
48
|
+
const regions = typeof given === "string" ? [given] : allowedRegions;
|
|
49
|
+
if (regions.length === 0) {
|
|
50
|
+
Annotations.of(scope).addWarningV2("fjall:scp-preset:empty-allowed-regions", `ScpPreset.allowedRegions is empty, so DenyOutsideAllowedRegions denies every action outside its exemptions in every member account. In the organisation's infrastructure.ts, remove allowedRegions from the enableScps call to allow the organisation's own regions, or ${LIST_THE_REGIONS}. 41.0.0 refuses an empty list.`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
regions.forEach((region, index) => {
|
|
54
|
+
if (!isAnyPartitionRegionCodeShape(region)) {
|
|
55
|
+
Annotations.of(scope).addWarningV2("fjall:scp-preset:not-a-region-code", `ScpPreset.allowedRegions entry ${index + 1} is not a region code, so DenyOutsideAllowedRegions can never allow the region it was meant to name. In the organisation's infrastructure.ts, write each entry as a region code such as eu-west-1, or remove allowedRegions from the enableScps call to allow the organisation's own regions. 41.0.0 refuses it.`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (!regions.includes(US_EAST_1)) {
|
|
59
|
+
Annotations.of(scope).addWarningV2("fjall:scp-preset:no-us-east-1", "ScpPreset.allowedRegions leaves out us-east-1, so member accounts cannot run CloudFormation there. A CDN's certificate stack and a domain takeover's ownership scan both need it.");
|
|
60
|
+
}
|
|
61
|
+
return typeof given === "string" ? given : [...regions];
|
|
62
|
+
}
|
|
9
63
|
// Every pattern below wildcards the partition segment: an SCP lives in one
|
|
10
64
|
// organisation's partition, and a literal `aws` would fail OPEN for the
|
|
11
65
|
// denies (a GovCloud root or volume never matches) and toward LOCKOUT for the
|
|
@@ -568,7 +622,7 @@ export class ScpPreset extends Construct {
|
|
|
568
622
|
// A template synthesises through tsx, which never typechecks, so a 39
|
|
569
623
|
// template that still names a level would otherwise deploy without a word.
|
|
570
624
|
refuseRemovedProps("ScpPreset", LEGACY_SCP_PRESET_PROPS, props);
|
|
571
|
-
this.createRootScps(props.rootId, props.allowedRegions);
|
|
625
|
+
this.createRootScps(props.rootId, resolveAllowedRegions(this, props.allowedRegions));
|
|
572
626
|
}
|
|
573
627
|
createRootScps(rootId, allowedRegions) {
|
|
574
628
|
const foundationPolicy = buildFoundationGuardrails(allowedRegions);
|