@beesolve/aws-accounts 1.2.0 → 1.2.1
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/applyLogic.js +407 -297
- package/dist/awsConfig.js +219 -187
- package/dist/cli.js +49 -23
- package/dist/commands/remote.js +69 -3
- package/dist/commands/validate.js +34 -4
- package/dist/diff.js +100 -25
- package/dist/operations.js +35 -2
- package/dist/scanLogic.js +84 -12
- package/dist/state.js +85 -5
- package/dist-lambda/handler.mjs +607 -316
- package/dist-lambda/lambda.zip +0 -0
- package/package.json +2 -1
package/dist-lambda/handler.mjs
CHANGED
|
@@ -792,6 +792,22 @@ var provisionIdcPermissionSetOperationSchema = strictObject({
|
|
|
792
792
|
permissionSetName: string(),
|
|
793
793
|
targetScope: literal("ALL_PROVISIONED_ACCOUNTS")
|
|
794
794
|
});
|
|
795
|
+
var permissionsBoundaryOperationValueSchema = union([
|
|
796
|
+
strictObject({ managedPolicyArn: string() }),
|
|
797
|
+
strictObject({
|
|
798
|
+
customerManagedPolicyName: string(),
|
|
799
|
+
customerManagedPolicyPath: string()
|
|
800
|
+
})
|
|
801
|
+
]);
|
|
802
|
+
var putIdcPermissionSetPermissionsBoundaryOperationSchema = strictObject({
|
|
803
|
+
kind: literal("putIdcPermissionSetPermissionsBoundary"),
|
|
804
|
+
permissionSetName: string(),
|
|
805
|
+
permissionsBoundary: permissionsBoundaryOperationValueSchema
|
|
806
|
+
});
|
|
807
|
+
var deleteIdcPermissionSetPermissionsBoundaryOperationSchema = strictObject({
|
|
808
|
+
kind: literal("deleteIdcPermissionSetPermissionsBoundary"),
|
|
809
|
+
permissionSetName: string()
|
|
810
|
+
});
|
|
795
811
|
var grantIdcAccountAssignmentOperationSchema = strictObject({
|
|
796
812
|
kind: literal("grantIdcAccountAssignment"),
|
|
797
813
|
accountName: string(),
|
|
@@ -836,6 +852,18 @@ var deleteAlternateContactOperationSchema = strictObject({
|
|
|
836
852
|
accountName: string(),
|
|
837
853
|
contactType: alternateContactTypeSchema
|
|
838
854
|
});
|
|
855
|
+
var registerDelegatedAdministratorOperationSchema = strictObject({
|
|
856
|
+
kind: literal("registerDelegatedAdministrator"),
|
|
857
|
+
accountId: string(),
|
|
858
|
+
accountName: string(),
|
|
859
|
+
servicePrincipal: string()
|
|
860
|
+
});
|
|
861
|
+
var deregisterDelegatedAdministratorOperationSchema = strictObject({
|
|
862
|
+
kind: literal("deregisterDelegatedAdministrator"),
|
|
863
|
+
accountId: string(),
|
|
864
|
+
accountName: string(),
|
|
865
|
+
servicePrincipal: string()
|
|
866
|
+
});
|
|
839
867
|
var createOrgPolicyOperationSchema = strictObject({
|
|
840
868
|
kind: literal("createOrgPolicy"),
|
|
841
869
|
policyName: string(),
|
|
@@ -843,7 +871,8 @@ var createOrgPolicyOperationSchema = strictObject({
|
|
|
843
871
|
"SERVICE_CONTROL_POLICY",
|
|
844
872
|
"RESOURCE_CONTROL_POLICY",
|
|
845
873
|
"TAG_POLICY",
|
|
846
|
-
"AISERVICES_OPT_OUT_POLICY"
|
|
874
|
+
"AISERVICES_OPT_OUT_POLICY",
|
|
875
|
+
"BACKUP_POLICY"
|
|
847
876
|
]),
|
|
848
877
|
description: string(),
|
|
849
878
|
content: string()
|
|
@@ -907,6 +936,8 @@ var operationSchema = variant("kind", [
|
|
|
907
936
|
attachIdcCustomerManagedPolicyReferenceToPermissionSetOperationSchema,
|
|
908
937
|
detachIdcCustomerManagedPolicyReferenceFromPermissionSetOperationSchema,
|
|
909
938
|
provisionIdcPermissionSetOperationSchema,
|
|
939
|
+
putIdcPermissionSetPermissionsBoundaryOperationSchema,
|
|
940
|
+
deleteIdcPermissionSetPermissionsBoundaryOperationSchema,
|
|
910
941
|
grantIdcAccountAssignmentOperationSchema,
|
|
911
942
|
revokeIdcAccountAssignmentOperationSchema,
|
|
912
943
|
createOrgPolicyOperationSchema,
|
|
@@ -917,7 +948,9 @@ var operationSchema = variant("kind", [
|
|
|
917
948
|
deleteOrgPolicyOperationSchema,
|
|
918
949
|
putAlternateContactOperationSchema,
|
|
919
950
|
deleteAlternateContactOperationSchema,
|
|
920
|
-
setIdcAccessControlAttributesOperationSchema
|
|
951
|
+
setIdcAccessControlAttributesOperationSchema,
|
|
952
|
+
registerDelegatedAdministratorOperationSchema,
|
|
953
|
+
deregisterDelegatedAdministratorOperationSchema
|
|
921
954
|
]);
|
|
922
955
|
var unsupportedDiffKindSchema = picklist([
|
|
923
956
|
"ambiguousOuRename",
|
|
@@ -971,7 +1004,8 @@ var orgPolicyTypeSchema = picklist([
|
|
|
971
1004
|
"SERVICE_CONTROL_POLICY",
|
|
972
1005
|
"RESOURCE_CONTROL_POLICY",
|
|
973
1006
|
"TAG_POLICY",
|
|
974
|
-
"AISERVICES_OPT_OUT_POLICY"
|
|
1007
|
+
"AISERVICES_OPT_OUT_POLICY",
|
|
1008
|
+
"BACKUP_POLICY"
|
|
975
1009
|
]);
|
|
976
1010
|
var orgPolicySchema = strictObject({
|
|
977
1011
|
id: nonEmptyString,
|
|
@@ -1027,6 +1061,13 @@ var customerManagedPolicyReferenceSchema = strictObject({
|
|
|
1027
1061
|
name: nonEmptyString,
|
|
1028
1062
|
path: nonEmptyString
|
|
1029
1063
|
});
|
|
1064
|
+
var permissionsBoundarySchema = union([
|
|
1065
|
+
strictObject({ managedPolicyArn: nonEmptyString }),
|
|
1066
|
+
strictObject({
|
|
1067
|
+
customerManagedPolicyName: nonEmptyString,
|
|
1068
|
+
customerManagedPolicyPath: nonEmptyString
|
|
1069
|
+
})
|
|
1070
|
+
]);
|
|
1030
1071
|
var permissionSetSchema = strictObject({
|
|
1031
1072
|
permissionSetArn: nonEmptyString,
|
|
1032
1073
|
name: nonEmptyString,
|
|
@@ -1034,7 +1075,8 @@ var permissionSetSchema = strictObject({
|
|
|
1034
1075
|
sessionDuration: nullable(string()),
|
|
1035
1076
|
inlinePolicy: nullable(nonEmptyString),
|
|
1036
1077
|
awsManagedPolicies: array(nonEmptyString),
|
|
1037
|
-
customerManagedPolicies: array(customerManagedPolicyReferenceSchema)
|
|
1078
|
+
customerManagedPolicies: array(customerManagedPolicyReferenceSchema),
|
|
1079
|
+
permissionsBoundary: nullable(permissionsBoundarySchema)
|
|
1038
1080
|
});
|
|
1039
1081
|
var accountAssignmentSchema = strictObject({
|
|
1040
1082
|
accountId: nonEmptyString,
|
|
@@ -1053,6 +1095,10 @@ var accessControlAttributeSchema = strictObject({
|
|
|
1053
1095
|
key: nonEmptyString,
|
|
1054
1096
|
source: array(nonEmptyString)
|
|
1055
1097
|
});
|
|
1098
|
+
var delegatedAdministratorSchema = strictObject({
|
|
1099
|
+
accountId: nonEmptyString,
|
|
1100
|
+
servicePrincipal: nonEmptyString
|
|
1101
|
+
});
|
|
1056
1102
|
var stateSchema = strictObject({
|
|
1057
1103
|
version: nonEmptyString,
|
|
1058
1104
|
generatedAt: nonEmptyString,
|
|
@@ -1061,7 +1107,8 @@ var stateSchema = strictObject({
|
|
|
1061
1107
|
organizationalUnits: array(organizationalUnitSchema),
|
|
1062
1108
|
accounts: array(accountSchema),
|
|
1063
1109
|
policies: optional(array(orgPolicySchema)),
|
|
1064
|
-
policyAttachments: optional(array(orgPolicyAttachmentSchema))
|
|
1110
|
+
policyAttachments: optional(array(orgPolicyAttachmentSchema)),
|
|
1111
|
+
delegatedAdministrators: optional(array(delegatedAdministratorSchema))
|
|
1065
1112
|
}),
|
|
1066
1113
|
identityCenter: strictObject({
|
|
1067
1114
|
instanceArn: nonEmptyString,
|
|
@@ -1078,6 +1125,7 @@ var stateSchema = strictObject({
|
|
|
1078
1125
|
function createWorkingState(props) {
|
|
1079
1126
|
const policies = props.state.organization.policies ?? [];
|
|
1080
1127
|
const policyAttachments = props.state.organization.policyAttachments ?? [];
|
|
1128
|
+
const delegatedAdministrators = props.state.organization.delegatedAdministrators ?? [];
|
|
1081
1129
|
return {
|
|
1082
1130
|
version: props.state.version,
|
|
1083
1131
|
generatedAt: props.state.generatedAt,
|
|
@@ -1098,6 +1146,11 @@ function createWorkingState(props) {
|
|
|
1098
1146
|
policyAttachmentsByKey: toRecordByProperty(
|
|
1099
1147
|
policyAttachments,
|
|
1100
1148
|
createOrgPolicyAttachmentKey
|
|
1149
|
+
),
|
|
1150
|
+
delegatedAdministrators: structuredClone(delegatedAdministrators),
|
|
1151
|
+
delegatedAdministratorsByKey: toRecordByProperty(
|
|
1152
|
+
delegatedAdministrators,
|
|
1153
|
+
createDelegatedAdministratorKey
|
|
1101
1154
|
)
|
|
1102
1155
|
},
|
|
1103
1156
|
identityCenter: createWorkingIdentityCenterState({
|
|
@@ -1118,7 +1171,12 @@ function materializeWorkingState(props) {
|
|
|
1118
1171
|
policies: Object.values(props.workingState.organization.policiesById),
|
|
1119
1172
|
policyAttachments: structuredClone(
|
|
1120
1173
|
props.workingState.organization.policyAttachments
|
|
1121
|
-
)
|
|
1174
|
+
),
|
|
1175
|
+
...props.workingState.organization.delegatedAdministrators.length > 0 ? {
|
|
1176
|
+
delegatedAdministrators: structuredClone(
|
|
1177
|
+
props.workingState.organization.delegatedAdministrators
|
|
1178
|
+
)
|
|
1179
|
+
} : {}
|
|
1122
1180
|
},
|
|
1123
1181
|
identityCenter: {
|
|
1124
1182
|
instanceArn: props.workingState.identityCenter.instanceArn,
|
|
@@ -1351,7 +1409,7 @@ function removeIdcGroupFromWorkingState(props) {
|
|
|
1351
1409
|
}
|
|
1352
1410
|
function upsertIdcPermissionSetInWorkingState(props) {
|
|
1353
1411
|
const currentPermissionSet = props.workingState.identityCenter.permissionSetsByName[props.permissionSet.name];
|
|
1354
|
-
if (currentPermissionSet != null && currentPermissionSet.permissionSetArn === props.permissionSet.permissionSetArn && currentPermissionSet.name === props.permissionSet.name && currentPermissionSet.description === props.permissionSet.description && currentPermissionSet.sessionDuration === props.permissionSet.sessionDuration && currentPermissionSet.inlinePolicy === props.permissionSet.inlinePolicy && JSON.stringify(currentPermissionSet.awsManagedPolicies) === JSON.stringify(props.permissionSet.awsManagedPolicies) && JSON.stringify(currentPermissionSet.customerManagedPolicies) === JSON.stringify(props.permissionSet.customerManagedPolicies)) {
|
|
1412
|
+
if (currentPermissionSet != null && currentPermissionSet.permissionSetArn === props.permissionSet.permissionSetArn && currentPermissionSet.name === props.permissionSet.name && currentPermissionSet.description === props.permissionSet.description && currentPermissionSet.sessionDuration === props.permissionSet.sessionDuration && currentPermissionSet.inlinePolicy === props.permissionSet.inlinePolicy && JSON.stringify(currentPermissionSet.awsManagedPolicies) === JSON.stringify(props.permissionSet.awsManagedPolicies) && JSON.stringify(currentPermissionSet.customerManagedPolicies) === JSON.stringify(props.permissionSet.customerManagedPolicies) && JSON.stringify(currentPermissionSet.permissionsBoundary) === JSON.stringify(props.permissionSet.permissionsBoundary)) {
|
|
1355
1413
|
return props.workingState;
|
|
1356
1414
|
}
|
|
1357
1415
|
const remainingPermissionSets = props.workingState.identityCenter.permissionSets.filter(
|
|
@@ -1588,6 +1646,59 @@ function removeOrgPolicyAttachmentFromWorkingState(props) {
|
|
|
1588
1646
|
}
|
|
1589
1647
|
};
|
|
1590
1648
|
}
|
|
1649
|
+
function createDelegatedAdministratorKey(props) {
|
|
1650
|
+
return [props.accountId, props.servicePrincipal].join("|");
|
|
1651
|
+
}
|
|
1652
|
+
function upsertDelegatedAdministratorInWorkingState(props) {
|
|
1653
|
+
const key = createDelegatedAdministratorKey({
|
|
1654
|
+
accountId: props.delegatedAdministrator.accountId,
|
|
1655
|
+
servicePrincipal: props.delegatedAdministrator.servicePrincipal
|
|
1656
|
+
});
|
|
1657
|
+
if (props.workingState.organization.delegatedAdministratorsByKey[key] != null) {
|
|
1658
|
+
return props.workingState;
|
|
1659
|
+
}
|
|
1660
|
+
const nextDelegatedAdministrators = [
|
|
1661
|
+
...props.workingState.organization.delegatedAdministrators,
|
|
1662
|
+
props.delegatedAdministrator
|
|
1663
|
+
];
|
|
1664
|
+
return {
|
|
1665
|
+
...props.workingState,
|
|
1666
|
+
organization: {
|
|
1667
|
+
...props.workingState.organization,
|
|
1668
|
+
delegatedAdministrators: nextDelegatedAdministrators,
|
|
1669
|
+
delegatedAdministratorsByKey: toRecordByProperty(
|
|
1670
|
+
nextDelegatedAdministrators,
|
|
1671
|
+
createDelegatedAdministratorKey
|
|
1672
|
+
)
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
function removeDelegatedAdministratorFromWorkingState(props) {
|
|
1677
|
+
const key = createDelegatedAdministratorKey({
|
|
1678
|
+
accountId: props.accountId,
|
|
1679
|
+
servicePrincipal: props.servicePrincipal
|
|
1680
|
+
});
|
|
1681
|
+
if (props.workingState.organization.delegatedAdministratorsByKey[key] == null) {
|
|
1682
|
+
return props.workingState;
|
|
1683
|
+
}
|
|
1684
|
+
const nextDelegatedAdministrators = props.workingState.organization.delegatedAdministrators.filter(
|
|
1685
|
+
(da) => createDelegatedAdministratorKey({
|
|
1686
|
+
accountId: da.accountId,
|
|
1687
|
+
servicePrincipal: da.servicePrincipal
|
|
1688
|
+
}) !== key
|
|
1689
|
+
);
|
|
1690
|
+
return {
|
|
1691
|
+
...props.workingState,
|
|
1692
|
+
organization: {
|
|
1693
|
+
...props.workingState.organization,
|
|
1694
|
+
delegatedAdministrators: nextDelegatedAdministrators,
|
|
1695
|
+
delegatedAdministratorsByKey: toRecordByProperty(
|
|
1696
|
+
nextDelegatedAdministrators,
|
|
1697
|
+
createDelegatedAdministratorKey
|
|
1698
|
+
)
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1591
1702
|
function createAccessRoleName(assignment) {
|
|
1592
1703
|
return `AWSReservedSSO_${assignment.permissionSetArn.split("/").at(-1) ?? "PermissionSet"}_${assignment.accountId}`;
|
|
1593
1704
|
}
|
|
@@ -1684,6 +1795,8 @@ import {
|
|
|
1684
1795
|
DescribeOrganizationCommand,
|
|
1685
1796
|
DescribePolicyCommand,
|
|
1686
1797
|
ListAccountsCommand,
|
|
1798
|
+
ListDelegatedAdministratorsCommand,
|
|
1799
|
+
ListDelegatedServicesForAccountCommand,
|
|
1687
1800
|
ListOrganizationalUnitsForParentCommand,
|
|
1688
1801
|
ListParentsCommand,
|
|
1689
1802
|
ListPoliciesCommand,
|
|
@@ -1694,6 +1807,7 @@ import {
|
|
|
1694
1807
|
import {
|
|
1695
1808
|
DescribePermissionSetCommand,
|
|
1696
1809
|
GetInlinePolicyForPermissionSetCommand,
|
|
1810
|
+
GetPermissionsBoundaryForPermissionSetCommand,
|
|
1697
1811
|
ListAccountAssignmentsCommand,
|
|
1698
1812
|
ListAccountsForProvisionedPermissionSetCommand,
|
|
1699
1813
|
ListCustomerManagedPolicyReferencesInPermissionSetCommand,
|
|
@@ -1766,22 +1880,65 @@ async function scanOrganization(props) {
|
|
|
1766
1880
|
}
|
|
1767
1881
|
nextToken = response.NextToken;
|
|
1768
1882
|
} while (nextToken != null);
|
|
1769
|
-
const { policies, policyAttachments } = await
|
|
1770
|
-
|
|
1771
|
-
|
|
1883
|
+
const [{ policies, policyAttachments }, delegatedAdministrators] = await Promise.all([
|
|
1884
|
+
scanOrganizationPolicies({
|
|
1885
|
+
organizationsClient: props.organizationsClient
|
|
1886
|
+
}),
|
|
1887
|
+
scanDelegatedAdministrators({
|
|
1888
|
+
organizationsClient: props.organizationsClient
|
|
1889
|
+
})
|
|
1890
|
+
]);
|
|
1772
1891
|
return {
|
|
1773
1892
|
rootId: root.Id,
|
|
1774
1893
|
organizationalUnits,
|
|
1775
1894
|
accounts,
|
|
1776
1895
|
policies,
|
|
1777
|
-
policyAttachments
|
|
1896
|
+
policyAttachments,
|
|
1897
|
+
delegatedAdministrators: delegatedAdministrators.length > 0 ? delegatedAdministrators : void 0
|
|
1778
1898
|
};
|
|
1779
1899
|
}
|
|
1900
|
+
async function scanDelegatedAdministrators(props) {
|
|
1901
|
+
const accountIds = new Array();
|
|
1902
|
+
let nextToken;
|
|
1903
|
+
do {
|
|
1904
|
+
const response = await props.organizationsClient.send(
|
|
1905
|
+
new ListDelegatedAdministratorsCommand({ NextToken: nextToken })
|
|
1906
|
+
);
|
|
1907
|
+
for (const admin of response.DelegatedAdministrators ?? []) {
|
|
1908
|
+
if (admin.Id == null) {
|
|
1909
|
+
continue;
|
|
1910
|
+
}
|
|
1911
|
+
accountIds.push(admin.Id);
|
|
1912
|
+
}
|
|
1913
|
+
nextToken = response.NextToken;
|
|
1914
|
+
} while (nextToken != null);
|
|
1915
|
+
const results = [];
|
|
1916
|
+
for (const accountId of accountIds) {
|
|
1917
|
+
let servicesNextToken;
|
|
1918
|
+
do {
|
|
1919
|
+
const response = await props.organizationsClient.send(
|
|
1920
|
+
new ListDelegatedServicesForAccountCommand({
|
|
1921
|
+
AccountId: accountId,
|
|
1922
|
+
NextToken: servicesNextToken
|
|
1923
|
+
})
|
|
1924
|
+
);
|
|
1925
|
+
for (const service of response.DelegatedServices ?? []) {
|
|
1926
|
+
if (service.ServicePrincipal == null) {
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1929
|
+
results.push({ accountId, servicePrincipal: service.ServicePrincipal });
|
|
1930
|
+
}
|
|
1931
|
+
servicesNextToken = response.NextToken;
|
|
1932
|
+
} while (servicesNextToken != null);
|
|
1933
|
+
}
|
|
1934
|
+
return results;
|
|
1935
|
+
}
|
|
1780
1936
|
var ORG_POLICY_TYPES = [
|
|
1781
1937
|
"SERVICE_CONTROL_POLICY",
|
|
1782
1938
|
"RESOURCE_CONTROL_POLICY",
|
|
1783
1939
|
"TAG_POLICY",
|
|
1784
|
-
"AISERVICES_OPT_OUT_POLICY"
|
|
1940
|
+
"AISERVICES_OPT_OUT_POLICY",
|
|
1941
|
+
"BACKUP_POLICY"
|
|
1785
1942
|
];
|
|
1786
1943
|
async function scanOrganizationPolicies(props) {
|
|
1787
1944
|
const policies = [];
|
|
@@ -2105,7 +2262,8 @@ async function listPermissionSets(props) {
|
|
|
2105
2262
|
const [
|
|
2106
2263
|
inlinePolicy,
|
|
2107
2264
|
awsManagedPolicies,
|
|
2108
|
-
customerManagedPolicies
|
|
2265
|
+
customerManagedPolicies,
|
|
2266
|
+
permissionsBoundary
|
|
2109
2267
|
] = await Promise.all([
|
|
2110
2268
|
getInlinePolicyForPermissionSet({
|
|
2111
2269
|
ssoAdminClient: props.ssoAdminClient,
|
|
@@ -2121,6 +2279,11 @@ async function listPermissionSets(props) {
|
|
|
2121
2279
|
ssoAdminClient: props.ssoAdminClient,
|
|
2122
2280
|
instanceArn: props.instanceArn,
|
|
2123
2281
|
permissionSetArn: permissionSet.PermissionSetArn
|
|
2282
|
+
}),
|
|
2283
|
+
getPermissionsBoundaryForPermissionSet({
|
|
2284
|
+
ssoAdminClient: props.ssoAdminClient,
|
|
2285
|
+
instanceArn: props.instanceArn,
|
|
2286
|
+
permissionSetArn: permissionSet.PermissionSetArn
|
|
2124
2287
|
})
|
|
2125
2288
|
]);
|
|
2126
2289
|
return {
|
|
@@ -2130,7 +2293,8 @@ async function listPermissionSets(props) {
|
|
|
2130
2293
|
sessionDuration: permissionSet.SessionDuration ?? null,
|
|
2131
2294
|
inlinePolicy,
|
|
2132
2295
|
awsManagedPolicies,
|
|
2133
|
-
customerManagedPolicies
|
|
2296
|
+
customerManagedPolicies,
|
|
2297
|
+
permissionsBoundary
|
|
2134
2298
|
};
|
|
2135
2299
|
})
|
|
2136
2300
|
);
|
|
@@ -2148,6 +2312,29 @@ async function getInlinePolicyForPermissionSet(props) {
|
|
|
2148
2312
|
const inlinePolicy = response.InlinePolicy?.trim();
|
|
2149
2313
|
return inlinePolicy != null && inlinePolicy.length > 0 ? inlinePolicy : null;
|
|
2150
2314
|
}
|
|
2315
|
+
async function getPermissionsBoundaryForPermissionSet(props) {
|
|
2316
|
+
const response = await props.ssoAdminClient.send(
|
|
2317
|
+
new GetPermissionsBoundaryForPermissionSetCommand({
|
|
2318
|
+
InstanceArn: props.instanceArn,
|
|
2319
|
+
PermissionSetArn: props.permissionSetArn
|
|
2320
|
+
})
|
|
2321
|
+
);
|
|
2322
|
+
const boundary = response.PermissionsBoundary;
|
|
2323
|
+
if (boundary == null) {
|
|
2324
|
+
return null;
|
|
2325
|
+
}
|
|
2326
|
+
if (boundary.ManagedPolicyArn != null) {
|
|
2327
|
+
return { managedPolicyArn: boundary.ManagedPolicyArn };
|
|
2328
|
+
}
|
|
2329
|
+
const ref = boundary.CustomerManagedPolicyReference;
|
|
2330
|
+
if (ref?.Name != null) {
|
|
2331
|
+
return {
|
|
2332
|
+
customerManagedPolicyName: ref.Name,
|
|
2333
|
+
customerManagedPolicyPath: ref.Path ?? "/"
|
|
2334
|
+
};
|
|
2335
|
+
}
|
|
2336
|
+
return null;
|
|
2337
|
+
}
|
|
2151
2338
|
async function listManagedPoliciesInPermissionSet(props) {
|
|
2152
2339
|
const managedPolicies = [];
|
|
2153
2340
|
let nextToken;
|
|
@@ -2245,11 +2432,7 @@ async function listAccountsForPermissionSet(props) {
|
|
|
2245
2432
|
} while (nextToken != null);
|
|
2246
2433
|
return accountIds;
|
|
2247
2434
|
}
|
|
2248
|
-
var ALTERNATE_CONTACT_TYPES = [
|
|
2249
|
-
"BILLING",
|
|
2250
|
-
"OPERATIONS",
|
|
2251
|
-
"SECURITY"
|
|
2252
|
-
];
|
|
2435
|
+
var ALTERNATE_CONTACT_TYPES = ["BILLING", "OPERATIONS", "SECURITY"];
|
|
2253
2436
|
async function scanAlternateContacts(props) {
|
|
2254
2437
|
const results = await Promise.all(
|
|
2255
2438
|
ALTERNATE_CONTACT_TYPES.map(async (contactType) => {
|
|
@@ -2292,12 +2475,14 @@ import {
|
|
|
2292
2475
|
AttachPolicyCommand,
|
|
2293
2476
|
CreateOrganizationalUnitCommand,
|
|
2294
2477
|
CreatePolicyCommand,
|
|
2478
|
+
DeregisterDelegatedAdministratorCommand,
|
|
2295
2479
|
DeleteOrganizationalUnitCommand,
|
|
2296
2480
|
DeletePolicyCommand,
|
|
2297
2481
|
DetachPolicyCommand,
|
|
2298
2482
|
ListAccountsForParentCommand,
|
|
2299
2483
|
ListOrganizationalUnitsForParentCommand as ListOrganizationalUnitsForParentCommand2,
|
|
2300
2484
|
MoveAccountCommand as MoveAccountCommand2,
|
|
2485
|
+
RegisterDelegatedAdministratorCommand,
|
|
2301
2486
|
TagResourceCommand,
|
|
2302
2487
|
UntagResourceCommand,
|
|
2303
2488
|
UpdateOrganizationalUnitCommand,
|
|
@@ -2321,6 +2506,7 @@ import {
|
|
|
2321
2506
|
CreatePermissionSetCommand,
|
|
2322
2507
|
DeleteAccountAssignmentCommand,
|
|
2323
2508
|
DeleteInlinePolicyFromPermissionSetCommand,
|
|
2509
|
+
DeletePermissionsBoundaryFromPermissionSetCommand,
|
|
2324
2510
|
DeletePermissionSetCommand,
|
|
2325
2511
|
DescribeAccountAssignmentCreationStatusCommand,
|
|
2326
2512
|
DescribeAccountAssignmentDeletionStatusCommand,
|
|
@@ -2329,6 +2515,7 @@ import {
|
|
|
2329
2515
|
DetachManagedPolicyFromPermissionSetCommand,
|
|
2330
2516
|
ProvisionPermissionSetCommand,
|
|
2331
2517
|
PutInlinePolicyToPermissionSetCommand,
|
|
2518
|
+
PutPermissionsBoundaryToPermissionSetCommand,
|
|
2332
2519
|
UpdateInstanceAccessControlAttributeConfigurationCommand,
|
|
2333
2520
|
UpdatePermissionSetCommand
|
|
2334
2521
|
} from "@aws-sdk/client-sso-admin";
|
|
@@ -2468,39 +2655,38 @@ function isCompleteAccountWithStatus(account, expectedAccountId) {
|
|
|
2468
2655
|
|
|
2469
2656
|
// src/applyLogic.ts
|
|
2470
2657
|
async function executeOperation(props) {
|
|
2471
|
-
|
|
2472
|
-
if (operation.kind === "moveAccount") {
|
|
2658
|
+
if (props.operation.kind === "moveAccount") {
|
|
2473
2659
|
props.logger.log(
|
|
2474
|
-
`Moving "${operation.accountName}" (${operation.accountId}): ${operation.fromOuName} -> ${operation.toOuName}`
|
|
2660
|
+
`Moving "${props.operation.accountName}" (${props.operation.accountId}): ${props.operation.fromOuName} -> ${props.operation.toOuName}`
|
|
2475
2661
|
);
|
|
2476
2662
|
await props.organizationsClient.send(
|
|
2477
2663
|
new MoveAccountCommand2({
|
|
2478
|
-
AccountId: operation.accountId,
|
|
2479
|
-
SourceParentId: operation.fromOuId,
|
|
2480
|
-
DestinationParentId: operation.toOuId
|
|
2664
|
+
AccountId: props.operation.accountId,
|
|
2665
|
+
SourceParentId: props.operation.fromOuId,
|
|
2666
|
+
DestinationParentId: props.operation.toOuId
|
|
2481
2667
|
})
|
|
2482
2668
|
);
|
|
2483
|
-
props.logger.log(`Done: "${operation.accountName}"`);
|
|
2669
|
+
props.logger.log(`Done: "${props.operation.accountName}"`);
|
|
2484
2670
|
return moveAccountInWorkingState({
|
|
2485
2671
|
workingState: props.state,
|
|
2486
|
-
accountId: operation.accountId,
|
|
2487
|
-
parentId: operation.toOuId
|
|
2672
|
+
accountId: props.operation.accountId,
|
|
2673
|
+
parentId: props.operation.toOuId
|
|
2488
2674
|
});
|
|
2489
2675
|
}
|
|
2490
|
-
if (operation.kind === "createOu") {
|
|
2676
|
+
if (props.operation.kind === "createOu") {
|
|
2491
2677
|
props.logger.log(
|
|
2492
|
-
`Creating OU "${operation.ouName}" under ${operation.parentOuName}...`
|
|
2678
|
+
`Creating OU "${props.operation.ouName}" under ${props.operation.parentOuName}...`
|
|
2493
2679
|
);
|
|
2494
2680
|
const response = await props.organizationsClient.send(
|
|
2495
2681
|
new CreateOrganizationalUnitCommand({
|
|
2496
|
-
ParentId: operation.parentOuId,
|
|
2497
|
-
Name: operation.ouName
|
|
2682
|
+
ParentId: props.operation.parentOuId,
|
|
2683
|
+
Name: props.operation.ouName
|
|
2498
2684
|
})
|
|
2499
2685
|
);
|
|
2500
2686
|
const createdOu = response.OrganizationalUnit;
|
|
2501
2687
|
if (createdOu?.Id == null || createdOu.Arn == null || createdOu.Name == null) {
|
|
2502
2688
|
throw new Error(
|
|
2503
|
-
`CreateOrganizationalUnit for "${operation.ouName}" returned incomplete OU data.`
|
|
2689
|
+
`CreateOrganizationalUnit for "${props.operation.ouName}" returned incomplete OU data.`
|
|
2504
2690
|
);
|
|
2505
2691
|
}
|
|
2506
2692
|
props.logger.log(`Done: "${createdOu.Name}"`);
|
|
@@ -2508,55 +2694,55 @@ async function executeOperation(props) {
|
|
|
2508
2694
|
workingState: props.state,
|
|
2509
2695
|
organizationalUnit: {
|
|
2510
2696
|
id: createdOu.Id,
|
|
2511
|
-
parentId: operation.parentOuId,
|
|
2697
|
+
parentId: props.operation.parentOuId,
|
|
2512
2698
|
arn: createdOu.Arn,
|
|
2513
2699
|
name: createdOu.Name
|
|
2514
2700
|
}
|
|
2515
2701
|
});
|
|
2516
2702
|
}
|
|
2517
|
-
if (operation.kind === "renameOu") {
|
|
2703
|
+
if (props.operation.kind === "renameOu") {
|
|
2518
2704
|
props.logger.log(
|
|
2519
|
-
`Renaming OU "${operation.fromOuName}" -> "${operation.toOuName}"...`
|
|
2705
|
+
`Renaming OU "${props.operation.fromOuName}" -> "${props.operation.toOuName}"...`
|
|
2520
2706
|
);
|
|
2521
2707
|
await props.organizationsClient.send(
|
|
2522
2708
|
new UpdateOrganizationalUnitCommand({
|
|
2523
|
-
OrganizationalUnitId: operation.ouId,
|
|
2524
|
-
Name: operation.toOuName
|
|
2709
|
+
OrganizationalUnitId: props.operation.ouId,
|
|
2710
|
+
Name: props.operation.toOuName
|
|
2525
2711
|
})
|
|
2526
2712
|
);
|
|
2527
|
-
props.logger.log(`Done: "${operation.toOuName}"`);
|
|
2713
|
+
props.logger.log(`Done: "${props.operation.toOuName}"`);
|
|
2528
2714
|
return renameOrganizationalUnitInWorkingState({
|
|
2529
2715
|
workingState: props.state,
|
|
2530
|
-
organizationalUnitId: operation.ouId,
|
|
2531
|
-
name: operation.toOuName
|
|
2716
|
+
organizationalUnitId: props.operation.ouId,
|
|
2717
|
+
name: props.operation.toOuName
|
|
2532
2718
|
});
|
|
2533
2719
|
}
|
|
2534
|
-
if (operation.kind === "deleteOu") {
|
|
2535
|
-
props.logger.log(`Deleting OU "${operation.ouName}"...`);
|
|
2720
|
+
if (props.operation.kind === "deleteOu") {
|
|
2721
|
+
props.logger.log(`Deleting OU "${props.operation.ouName}"...`);
|
|
2536
2722
|
await assertOrganizationalUnitIsEmpty({
|
|
2537
2723
|
organizationsClient: props.organizationsClient,
|
|
2538
|
-
organizationalUnitId: operation.ouId,
|
|
2539
|
-
organizationalUnitName: operation.ouName
|
|
2724
|
+
organizationalUnitId: props.operation.ouId,
|
|
2725
|
+
organizationalUnitName: props.operation.ouName
|
|
2540
2726
|
});
|
|
2541
2727
|
await props.organizationsClient.send(
|
|
2542
2728
|
new DeleteOrganizationalUnitCommand({
|
|
2543
|
-
OrganizationalUnitId: operation.ouId
|
|
2729
|
+
OrganizationalUnitId: props.operation.ouId
|
|
2544
2730
|
})
|
|
2545
2731
|
);
|
|
2546
|
-
props.logger.log(`Done: "${operation.ouName}"`);
|
|
2732
|
+
props.logger.log(`Done: "${props.operation.ouName}"`);
|
|
2547
2733
|
return removeOrganizationalUnitFromWorkingState({
|
|
2548
2734
|
workingState: props.state,
|
|
2549
|
-
organizationalUnitId: operation.ouId
|
|
2735
|
+
organizationalUnitId: props.operation.ouId
|
|
2550
2736
|
});
|
|
2551
2737
|
}
|
|
2552
|
-
if (operation.kind === "createAccount") {
|
|
2738
|
+
if (props.operation.kind === "createAccount") {
|
|
2553
2739
|
const result = await createAccountAndMoveToOu({
|
|
2554
2740
|
organizationsClient: props.organizationsClient,
|
|
2555
2741
|
logger: props.logger,
|
|
2556
|
-
accountName: operation.accountName,
|
|
2557
|
-
accountEmail: operation.accountEmail,
|
|
2742
|
+
accountName: props.operation.accountName,
|
|
2743
|
+
accountEmail: props.operation.accountEmail,
|
|
2558
2744
|
sourceParentId: props.context.organization.rootId,
|
|
2559
|
-
destinationParentId: operation.targetOuId,
|
|
2745
|
+
destinationParentId: props.operation.targetOuId,
|
|
2560
2746
|
timeoutInMs: props.runtime.createAccount.timeoutInMs,
|
|
2561
2747
|
pollIntervalInMs: props.runtime.createAccount.pollIntervalInMs
|
|
2562
2748
|
});
|
|
@@ -2568,33 +2754,33 @@ async function executeOperation(props) {
|
|
|
2568
2754
|
name: result.account.name,
|
|
2569
2755
|
email: result.account.email,
|
|
2570
2756
|
status: result.account.status,
|
|
2571
|
-
parentId: operation.targetOuId,
|
|
2757
|
+
parentId: props.operation.targetOuId,
|
|
2572
2758
|
tags: []
|
|
2573
2759
|
}
|
|
2574
2760
|
});
|
|
2575
2761
|
}
|
|
2576
|
-
if (operation.kind === "updateAccountTags") {
|
|
2577
|
-
const account = props.state.organization.accountsById[operation.accountId];
|
|
2762
|
+
if (props.operation.kind === "updateAccountTags") {
|
|
2763
|
+
const account = props.state.organization.accountsById[props.operation.accountId];
|
|
2578
2764
|
if (account == null) {
|
|
2579
2765
|
throw new Error(
|
|
2580
|
-
`Could not resolve account "${operation.accountName}" (${operation.accountId}) in working state.`
|
|
2766
|
+
`Could not resolve account "${props.operation.accountName}" (${props.operation.accountId}) in working state.`
|
|
2581
2767
|
);
|
|
2582
2768
|
}
|
|
2583
2769
|
const currentTags = new Map(
|
|
2584
2770
|
(account.tags ?? []).map((tag) => [tag.key, tag.value])
|
|
2585
2771
|
);
|
|
2586
|
-
const desiredTags = new Map(Object.entries(operation.tags));
|
|
2772
|
+
const desiredTags = new Map(Object.entries(props.operation.tags));
|
|
2587
2773
|
const tagsToApply = [...desiredTags.entries()].filter(([key, value]) => currentTags.get(key) !== value).map(([Key, Value]) => ({ Key, Value }));
|
|
2588
2774
|
const tagKeysToRemove = [...currentTags.keys()].filter(
|
|
2589
2775
|
(key) => desiredTags.has(key) === false
|
|
2590
2776
|
);
|
|
2591
2777
|
props.logger.log(
|
|
2592
|
-
`Updating account tags "${operation.accountName}" (${operation.accountId})...`
|
|
2778
|
+
`Updating account tags "${props.operation.accountName}" (${props.operation.accountId})...`
|
|
2593
2779
|
);
|
|
2594
2780
|
if (tagsToApply.length > 0) {
|
|
2595
2781
|
await props.organizationsClient.send(
|
|
2596
2782
|
new TagResourceCommand({
|
|
2597
|
-
ResourceId: operation.accountId,
|
|
2783
|
+
ResourceId: props.operation.accountId,
|
|
2598
2784
|
Tags: tagsToApply
|
|
2599
2785
|
})
|
|
2600
2786
|
);
|
|
@@ -2602,84 +2788,84 @@ async function executeOperation(props) {
|
|
|
2602
2788
|
if (tagKeysToRemove.length > 0) {
|
|
2603
2789
|
await props.organizationsClient.send(
|
|
2604
2790
|
new UntagResourceCommand({
|
|
2605
|
-
ResourceId: operation.accountId,
|
|
2791
|
+
ResourceId: props.operation.accountId,
|
|
2606
2792
|
TagKeys: tagKeysToRemove
|
|
2607
2793
|
})
|
|
2608
2794
|
);
|
|
2609
2795
|
}
|
|
2610
|
-
props.logger.log(`Done: tags updated for "${operation.accountName}"`);
|
|
2796
|
+
props.logger.log(`Done: tags updated for "${props.operation.accountName}"`);
|
|
2611
2797
|
return upsertAccountInWorkingState({
|
|
2612
2798
|
workingState: props.state,
|
|
2613
2799
|
account: {
|
|
2614
2800
|
...account,
|
|
2615
|
-
tags: Object.entries(operation.tags).map(([key, value]) => ({
|
|
2801
|
+
tags: Object.entries(props.operation.tags).map(([key, value]) => ({
|
|
2616
2802
|
key,
|
|
2617
2803
|
value
|
|
2618
2804
|
}))
|
|
2619
2805
|
}
|
|
2620
2806
|
});
|
|
2621
2807
|
}
|
|
2622
|
-
if (operation.kind === "updateAccountName") {
|
|
2808
|
+
if (props.operation.kind === "updateAccountName") {
|
|
2623
2809
|
props.logger.log(
|
|
2624
|
-
`Renaming account (${operation.accountId}): "${operation.fromAccountName}" -> "${operation.toAccountName}"...`
|
|
2810
|
+
`Renaming account (${props.operation.accountId}): "${props.operation.fromAccountName}" -> "${props.operation.toAccountName}"...`
|
|
2625
2811
|
);
|
|
2626
2812
|
await props.accountClient.send(
|
|
2627
2813
|
new PutAccountNameCommand({
|
|
2628
|
-
AccountId: operation.accountId,
|
|
2629
|
-
AccountName: operation.toAccountName
|
|
2814
|
+
AccountId: props.operation.accountId,
|
|
2815
|
+
AccountName: props.operation.toAccountName
|
|
2630
2816
|
})
|
|
2631
2817
|
);
|
|
2632
2818
|
props.logger.log(
|
|
2633
|
-
`Done: account "${operation.toAccountName}" (${operation.accountId})`
|
|
2819
|
+
`Done: account "${props.operation.toAccountName}" (${props.operation.accountId})`
|
|
2634
2820
|
);
|
|
2635
|
-
const account = props.state.organization.accountsById[operation.accountId];
|
|
2821
|
+
const account = props.state.organization.accountsById[props.operation.accountId];
|
|
2636
2822
|
if (account == null) {
|
|
2637
2823
|
throw new Error(
|
|
2638
|
-
`Could not resolve account (${operation.accountId}) in working state after rename.`
|
|
2824
|
+
`Could not resolve account (${props.operation.accountId}) in working state after rename.`
|
|
2639
2825
|
);
|
|
2640
2826
|
}
|
|
2641
2827
|
return upsertAccountInWorkingState({
|
|
2642
2828
|
workingState: props.state,
|
|
2643
2829
|
account: {
|
|
2644
2830
|
...account,
|
|
2645
|
-
name: operation.toAccountName
|
|
2831
|
+
name: props.operation.toAccountName
|
|
2646
2832
|
}
|
|
2647
2833
|
});
|
|
2648
2834
|
}
|
|
2649
|
-
if (operation.kind === "removeAccount") {
|
|
2835
|
+
if (props.operation.kind === "removeAccount") {
|
|
2650
2836
|
props.logger.log(
|
|
2651
|
-
`Moving removed account "${operation.accountName}" (${operation.accountId}) to ${operation.toOuName}...`
|
|
2837
|
+
`Moving removed account "${props.operation.accountName}" (${props.operation.accountId}) to ${props.operation.toOuName}...`
|
|
2652
2838
|
);
|
|
2653
2839
|
await props.organizationsClient.send(
|
|
2654
2840
|
new MoveAccountCommand2({
|
|
2655
|
-
AccountId: operation.accountId,
|
|
2656
|
-
SourceParentId: operation.fromOuId,
|
|
2657
|
-
DestinationParentId: operation.toOuId
|
|
2841
|
+
AccountId: props.operation.accountId,
|
|
2842
|
+
SourceParentId: props.operation.fromOuId,
|
|
2843
|
+
DestinationParentId: props.operation.toOuId
|
|
2658
2844
|
})
|
|
2659
2845
|
);
|
|
2660
2846
|
props.logger.log(
|
|
2661
|
-
`Done: "${operation.accountName}" -> ${operation.toOuName}`
|
|
2847
|
+
`Done: "${props.operation.accountName}" -> ${props.operation.toOuName}`
|
|
2662
2848
|
);
|
|
2663
2849
|
return moveAccountInWorkingState({
|
|
2664
2850
|
workingState: props.state,
|
|
2665
|
-
accountId: operation.accountId,
|
|
2666
|
-
parentId: operation.toOuId
|
|
2851
|
+
accountId: props.operation.accountId,
|
|
2852
|
+
parentId: props.operation.toOuId
|
|
2667
2853
|
});
|
|
2668
2854
|
}
|
|
2669
|
-
if (operation.kind === "createIdcUser") {
|
|
2670
|
-
props.logger.log(`Creating IdC user "${operation.userName}"...`);
|
|
2855
|
+
if (props.operation.kind === "createIdcUser") {
|
|
2856
|
+
props.logger.log(`Creating IdC user "${props.operation.userName}"...`);
|
|
2671
2857
|
const response = await props.identityStoreClient.send(
|
|
2672
2858
|
new CreateUserCommand({
|
|
2673
2859
|
IdentityStoreId: props.state.identityCenter.identityStoreId,
|
|
2674
|
-
UserName: operation.userName,
|
|
2675
|
-
DisplayName: operation.displayName,
|
|
2860
|
+
UserName: props.operation.userName,
|
|
2861
|
+
DisplayName: props.operation.displayName,
|
|
2676
2862
|
Name: buildIdentityStoreUserName({
|
|
2677
|
-
userName: operation.userName,
|
|
2678
|
-
displayName: operation.displayName
|
|
2863
|
+
userName: props.operation.userName,
|
|
2864
|
+
displayName: props.operation.displayName
|
|
2679
2865
|
}),
|
|
2680
|
-
Emails: operation.email.length > 0 ? [
|
|
2866
|
+
Emails: props.operation.email.length > 0 ? [
|
|
2681
2867
|
{
|
|
2682
|
-
Value: operation.email,
|
|
2868
|
+
Value: props.operation.email,
|
|
2683
2869
|
Type: "Work",
|
|
2684
2870
|
Primary: true
|
|
2685
2871
|
}
|
|
@@ -2688,45 +2874,45 @@ async function executeOperation(props) {
|
|
|
2688
2874
|
);
|
|
2689
2875
|
if (response.UserId == null) {
|
|
2690
2876
|
throw new Error(
|
|
2691
|
-
`CreateUser for "${operation.userName}" returned no user id.`
|
|
2877
|
+
`CreateUser for "${props.operation.userName}" returned no user id.`
|
|
2692
2878
|
);
|
|
2693
2879
|
}
|
|
2694
|
-
props.logger.log(`Done: "${operation.userName}"`);
|
|
2880
|
+
props.logger.log(`Done: "${props.operation.userName}"`);
|
|
2695
2881
|
return upsertIdcUserInWorkingState({
|
|
2696
2882
|
workingState: props.state,
|
|
2697
2883
|
user: {
|
|
2698
2884
|
userId: response.UserId,
|
|
2699
|
-
userName: operation.userName,
|
|
2700
|
-
displayName: operation.displayName,
|
|
2701
|
-
email: operation.email
|
|
2885
|
+
userName: props.operation.userName,
|
|
2886
|
+
displayName: props.operation.displayName,
|
|
2887
|
+
email: props.operation.email
|
|
2702
2888
|
}
|
|
2703
2889
|
});
|
|
2704
2890
|
}
|
|
2705
|
-
if (operation.kind === "updateIdcUser") {
|
|
2891
|
+
if (props.operation.kind === "updateIdcUser") {
|
|
2706
2892
|
const user = resolveUserByName({
|
|
2707
2893
|
state: props.state,
|
|
2708
|
-
userName: operation.userName
|
|
2894
|
+
userName: props.operation.userName
|
|
2709
2895
|
});
|
|
2710
2896
|
const operations = [];
|
|
2711
|
-
if (user.displayName !== operation.displayName) {
|
|
2897
|
+
if (user.displayName !== props.operation.displayName) {
|
|
2712
2898
|
operations.push({
|
|
2713
2899
|
AttributePath: "displayName",
|
|
2714
|
-
AttributeValue: operation.displayName
|
|
2900
|
+
AttributeValue: props.operation.displayName
|
|
2715
2901
|
});
|
|
2716
2902
|
operations.push({
|
|
2717
2903
|
AttributePath: "name",
|
|
2718
2904
|
AttributeValue: buildIdentityStoreUserName({
|
|
2719
|
-
userName: operation.userName,
|
|
2720
|
-
displayName: operation.displayName
|
|
2905
|
+
userName: props.operation.userName,
|
|
2906
|
+
displayName: props.operation.displayName
|
|
2721
2907
|
})
|
|
2722
2908
|
});
|
|
2723
2909
|
}
|
|
2724
|
-
if (user.email !== operation.email && operation.email.length > 0) {
|
|
2910
|
+
if (user.email !== props.operation.email && props.operation.email.length > 0) {
|
|
2725
2911
|
operations.push({
|
|
2726
2912
|
AttributePath: "emails",
|
|
2727
2913
|
AttributeValue: [
|
|
2728
2914
|
{
|
|
2729
|
-
Value: operation.email,
|
|
2915
|
+
Value: props.operation.email,
|
|
2730
2916
|
Type: "Work",
|
|
2731
2917
|
Primary: true
|
|
2732
2918
|
}
|
|
@@ -2736,7 +2922,7 @@ async function executeOperation(props) {
|
|
|
2736
2922
|
if (operations.length === 0) {
|
|
2737
2923
|
return props.state;
|
|
2738
2924
|
}
|
|
2739
|
-
props.logger.log(`Updating IdC user "${operation.userName}"...`);
|
|
2925
|
+
props.logger.log(`Updating IdC user "${props.operation.userName}"...`);
|
|
2740
2926
|
await props.identityStoreClient.send(
|
|
2741
2927
|
new UpdateUserCommand({
|
|
2742
2928
|
IdentityStoreId: props.state.identityCenter.identityStoreId,
|
|
@@ -2744,65 +2930,65 @@ async function executeOperation(props) {
|
|
|
2744
2930
|
Operations: operations
|
|
2745
2931
|
})
|
|
2746
2932
|
);
|
|
2747
|
-
props.logger.log(`Done: "${operation.userName}"`);
|
|
2933
|
+
props.logger.log(`Done: "${props.operation.userName}"`);
|
|
2748
2934
|
return upsertIdcUserInWorkingState({
|
|
2749
2935
|
workingState: props.state,
|
|
2750
2936
|
user: {
|
|
2751
2937
|
...user,
|
|
2752
|
-
displayName: operation.displayName,
|
|
2753
|
-
email: operation.email.length > 0 ? operation.email : user.email
|
|
2938
|
+
displayName: props.operation.displayName,
|
|
2939
|
+
email: props.operation.email.length > 0 ? props.operation.email : user.email
|
|
2754
2940
|
}
|
|
2755
2941
|
});
|
|
2756
2942
|
}
|
|
2757
|
-
if (operation.kind === "deleteIdcUser") {
|
|
2943
|
+
if (props.operation.kind === "deleteIdcUser") {
|
|
2758
2944
|
const user = resolveUserByName({
|
|
2759
2945
|
state: props.state,
|
|
2760
|
-
userName: operation.userName
|
|
2946
|
+
userName: props.operation.userName
|
|
2761
2947
|
});
|
|
2762
|
-
props.logger.log(`Deleting IdC user "${operation.userName}"...`);
|
|
2948
|
+
props.logger.log(`Deleting IdC user "${props.operation.userName}"...`);
|
|
2763
2949
|
await props.identityStoreClient.send(
|
|
2764
2950
|
new DeleteUserCommand({
|
|
2765
2951
|
IdentityStoreId: props.state.identityCenter.identityStoreId,
|
|
2766
2952
|
UserId: user.userId
|
|
2767
2953
|
})
|
|
2768
2954
|
);
|
|
2769
|
-
props.logger.log(`Done: "${operation.userName}"`);
|
|
2955
|
+
props.logger.log(`Done: "${props.operation.userName}"`);
|
|
2770
2956
|
return removeIdcUserFromWorkingState({
|
|
2771
2957
|
workingState: props.state,
|
|
2772
|
-
userName: operation.userName
|
|
2958
|
+
userName: props.operation.userName
|
|
2773
2959
|
});
|
|
2774
2960
|
}
|
|
2775
|
-
if (operation.kind === "createIdcGroup") {
|
|
2776
|
-
props.logger.log(`Creating IdC group "${operation.groupDisplayName}"...`);
|
|
2961
|
+
if (props.operation.kind === "createIdcGroup") {
|
|
2962
|
+
props.logger.log(`Creating IdC group "${props.operation.groupDisplayName}"...`);
|
|
2777
2963
|
const response = await props.identityStoreClient.send(
|
|
2778
2964
|
new CreateGroupCommand({
|
|
2779
2965
|
IdentityStoreId: props.state.identityCenter.identityStoreId,
|
|
2780
|
-
DisplayName: operation.groupDisplayName,
|
|
2781
|
-
Description: operation.description.trim().length > 0 ? operation.description : void 0
|
|
2966
|
+
DisplayName: props.operation.groupDisplayName,
|
|
2967
|
+
Description: props.operation.description.trim().length > 0 ? props.operation.description : void 0
|
|
2782
2968
|
})
|
|
2783
2969
|
);
|
|
2784
2970
|
if (response.GroupId == null) {
|
|
2785
2971
|
throw new Error(
|
|
2786
|
-
`CreateGroup for "${operation.groupDisplayName}" returned no group id.`
|
|
2972
|
+
`CreateGroup for "${props.operation.groupDisplayName}" returned no group id.`
|
|
2787
2973
|
);
|
|
2788
2974
|
}
|
|
2789
|
-
props.logger.log(`Done: "${operation.groupDisplayName}"`);
|
|
2975
|
+
props.logger.log(`Done: "${props.operation.groupDisplayName}"`);
|
|
2790
2976
|
return upsertIdcGroupInWorkingState({
|
|
2791
2977
|
workingState: props.state,
|
|
2792
2978
|
group: {
|
|
2793
2979
|
groupId: response.GroupId,
|
|
2794
|
-
displayName: operation.groupDisplayName,
|
|
2795
|
-
description: operation.description
|
|
2980
|
+
displayName: props.operation.groupDisplayName,
|
|
2981
|
+
description: props.operation.description
|
|
2796
2982
|
}
|
|
2797
2983
|
});
|
|
2798
2984
|
}
|
|
2799
|
-
if (operation.kind === "updateIdcGroupDescription") {
|
|
2985
|
+
if (props.operation.kind === "updateIdcGroupDescription") {
|
|
2800
2986
|
const group = resolveGroupByDisplayName({
|
|
2801
2987
|
state: props.state,
|
|
2802
|
-
groupDisplayName: operation.groupDisplayName
|
|
2988
|
+
groupDisplayName: props.operation.groupDisplayName
|
|
2803
2989
|
});
|
|
2804
2990
|
props.logger.log(
|
|
2805
|
-
`Updating IdC group description for "${operation.groupDisplayName}"...`
|
|
2991
|
+
`Updating IdC group description for "${props.operation.groupDisplayName}"...`
|
|
2806
2992
|
);
|
|
2807
2993
|
await props.identityStoreClient.send(
|
|
2808
2994
|
new UpdateGroupCommand({
|
|
@@ -2811,46 +2997,46 @@ async function executeOperation(props) {
|
|
|
2811
2997
|
Operations: [
|
|
2812
2998
|
{
|
|
2813
2999
|
AttributePath: "description",
|
|
2814
|
-
AttributeValue: operation.description
|
|
3000
|
+
AttributeValue: props.operation.description
|
|
2815
3001
|
}
|
|
2816
3002
|
]
|
|
2817
3003
|
})
|
|
2818
3004
|
);
|
|
2819
|
-
props.logger.log(`Done: group "${operation.groupDisplayName}"`);
|
|
3005
|
+
props.logger.log(`Done: group "${props.operation.groupDisplayName}"`);
|
|
2820
3006
|
return upsertIdcGroupInWorkingState({
|
|
2821
3007
|
workingState: props.state,
|
|
2822
3008
|
group: {
|
|
2823
3009
|
...group,
|
|
2824
|
-
description: operation.description
|
|
3010
|
+
description: props.operation.description
|
|
2825
3011
|
}
|
|
2826
3012
|
});
|
|
2827
3013
|
}
|
|
2828
|
-
if (operation.kind === "deleteIdcGroup") {
|
|
3014
|
+
if (props.operation.kind === "deleteIdcGroup") {
|
|
2829
3015
|
const group = resolveGroupByDisplayName({
|
|
2830
3016
|
state: props.state,
|
|
2831
|
-
groupDisplayName: operation.groupDisplayName
|
|
3017
|
+
groupDisplayName: props.operation.groupDisplayName
|
|
2832
3018
|
});
|
|
2833
|
-
props.logger.log(`Deleting IdC group "${operation.groupDisplayName}"...`);
|
|
3019
|
+
props.logger.log(`Deleting IdC group "${props.operation.groupDisplayName}"...`);
|
|
2834
3020
|
await props.identityStoreClient.send(
|
|
2835
3021
|
new DeleteGroupCommand({
|
|
2836
3022
|
IdentityStoreId: props.state.identityCenter.identityStoreId,
|
|
2837
3023
|
GroupId: group.groupId
|
|
2838
3024
|
})
|
|
2839
3025
|
);
|
|
2840
|
-
props.logger.log(`Done: "${operation.groupDisplayName}"`);
|
|
3026
|
+
props.logger.log(`Done: "${props.operation.groupDisplayName}"`);
|
|
2841
3027
|
return removeIdcGroupFromWorkingState({
|
|
2842
3028
|
workingState: props.state,
|
|
2843
|
-
groupDisplayName: operation.groupDisplayName
|
|
3029
|
+
groupDisplayName: props.operation.groupDisplayName
|
|
2844
3030
|
});
|
|
2845
3031
|
}
|
|
2846
|
-
if (operation.kind === "addIdcGroupMembership") {
|
|
3032
|
+
if (props.operation.kind === "addIdcGroupMembership") {
|
|
2847
3033
|
const resolvedMembership = resolveGroupMembershipDependencies({
|
|
2848
3034
|
state: props.state,
|
|
2849
|
-
groupDisplayName: operation.groupDisplayName,
|
|
2850
|
-
userName: operation.userName
|
|
3035
|
+
groupDisplayName: props.operation.groupDisplayName,
|
|
3036
|
+
userName: props.operation.userName
|
|
2851
3037
|
});
|
|
2852
3038
|
props.logger.log(
|
|
2853
|
-
`Adding user "${operation.userName}" to IdC group "${operation.groupDisplayName}"...`
|
|
3039
|
+
`Adding user "${props.operation.userName}" to IdC group "${props.operation.groupDisplayName}"...`
|
|
2854
3040
|
);
|
|
2855
3041
|
const response = await props.identityStoreClient.send(
|
|
2856
3042
|
new CreateGroupMembershipCommand({
|
|
@@ -2863,11 +3049,11 @@ async function executeOperation(props) {
|
|
|
2863
3049
|
);
|
|
2864
3050
|
if (response.MembershipId == null) {
|
|
2865
3051
|
throw new Error(
|
|
2866
|
-
`CreateGroupMembership for group "${operation.groupDisplayName}" and user "${operation.userName}" returned no membership id.`
|
|
3052
|
+
`CreateGroupMembership for group "${props.operation.groupDisplayName}" and user "${props.operation.userName}" returned no membership id.`
|
|
2867
3053
|
);
|
|
2868
3054
|
}
|
|
2869
3055
|
props.logger.log(
|
|
2870
|
-
`Done: user "${operation.userName}" -> group "${operation.groupDisplayName}"`
|
|
3056
|
+
`Done: user "${props.operation.userName}" -> group "${props.operation.groupDisplayName}"`
|
|
2871
3057
|
);
|
|
2872
3058
|
return addGroupMembershipToWorkingState({
|
|
2873
3059
|
workingState: props.state,
|
|
@@ -2878,93 +3064,94 @@ async function executeOperation(props) {
|
|
|
2878
3064
|
}
|
|
2879
3065
|
});
|
|
2880
3066
|
}
|
|
2881
|
-
if (operation.kind === "createIdcPermissionSet") {
|
|
3067
|
+
if (props.operation.kind === "createIdcPermissionSet") {
|
|
2882
3068
|
props.logger.log(
|
|
2883
|
-
`Creating IdC permission set "${operation.permissionSetName}"...`
|
|
3069
|
+
`Creating IdC permission set "${props.operation.permissionSetName}"...`
|
|
2884
3070
|
);
|
|
2885
3071
|
const response = await props.ssoAdminClient.send(
|
|
2886
3072
|
new CreatePermissionSetCommand({
|
|
2887
3073
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
2888
|
-
Name: operation.permissionSetName,
|
|
2889
|
-
Description: operation.description.length > 0 ? operation.description : void 0,
|
|
2890
|
-
SessionDuration: operation.sessionDuration ?? void 0
|
|
3074
|
+
Name: props.operation.permissionSetName,
|
|
3075
|
+
Description: props.operation.description.length > 0 ? props.operation.description : void 0,
|
|
3076
|
+
SessionDuration: props.operation.sessionDuration ?? void 0
|
|
2891
3077
|
})
|
|
2892
3078
|
);
|
|
2893
3079
|
const permissionSetArn = response.PermissionSet?.PermissionSetArn;
|
|
2894
3080
|
if (permissionSetArn == null) {
|
|
2895
3081
|
throw new Error(
|
|
2896
|
-
`CreatePermissionSet for "${operation.permissionSetName}" returned no permission set arn.`
|
|
3082
|
+
`CreatePermissionSet for "${props.operation.permissionSetName}" returned no permission set arn.`
|
|
2897
3083
|
);
|
|
2898
3084
|
}
|
|
2899
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3085
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
2900
3086
|
return upsertIdcPermissionSetInWorkingState({
|
|
2901
3087
|
workingState: props.state,
|
|
2902
3088
|
permissionSet: {
|
|
2903
3089
|
permissionSetArn,
|
|
2904
|
-
name: operation.permissionSetName,
|
|
2905
|
-
description: operation.description,
|
|
2906
|
-
sessionDuration: operation.sessionDuration,
|
|
3090
|
+
name: props.operation.permissionSetName,
|
|
3091
|
+
description: props.operation.description,
|
|
3092
|
+
sessionDuration: props.operation.sessionDuration,
|
|
2907
3093
|
inlinePolicy: null,
|
|
2908
3094
|
awsManagedPolicies: [],
|
|
2909
|
-
customerManagedPolicies: []
|
|
3095
|
+
customerManagedPolicies: [],
|
|
3096
|
+
permissionsBoundary: null
|
|
2910
3097
|
}
|
|
2911
3098
|
});
|
|
2912
3099
|
}
|
|
2913
|
-
if (operation.kind === "updateIdcPermissionSetDescription") {
|
|
3100
|
+
if (props.operation.kind === "updateIdcPermissionSetDescription") {
|
|
2914
3101
|
const permissionSet = resolvePermissionSetByName({
|
|
2915
3102
|
state: props.state,
|
|
2916
|
-
permissionSetName: operation.permissionSetName
|
|
3103
|
+
permissionSetName: props.operation.permissionSetName
|
|
2917
3104
|
});
|
|
2918
3105
|
props.logger.log(
|
|
2919
|
-
`Updating IdC permission set description for "${operation.permissionSetName}"...`
|
|
3106
|
+
`Updating IdC permission set description for "${props.operation.permissionSetName}"...`
|
|
2920
3107
|
);
|
|
2921
3108
|
await props.ssoAdminClient.send(
|
|
2922
3109
|
new UpdatePermissionSetCommand({
|
|
2923
3110
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
2924
3111
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
2925
|
-
Description: operation.description.trim().length > 0 ? operation.description : void 0
|
|
3112
|
+
Description: props.operation.description.trim().length > 0 ? props.operation.description : void 0
|
|
2926
3113
|
})
|
|
2927
3114
|
);
|
|
2928
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3115
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
2929
3116
|
return upsertIdcPermissionSetInWorkingState({
|
|
2930
3117
|
workingState: props.state,
|
|
2931
3118
|
permissionSet: {
|
|
2932
3119
|
...permissionSet,
|
|
2933
|
-
description: operation.description
|
|
3120
|
+
description: props.operation.description
|
|
2934
3121
|
}
|
|
2935
3122
|
});
|
|
2936
3123
|
}
|
|
2937
|
-
if (operation.kind === "updateIdcPermissionSetSessionDuration") {
|
|
3124
|
+
if (props.operation.kind === "updateIdcPermissionSetSessionDuration") {
|
|
2938
3125
|
const permissionSet = resolvePermissionSetByName({
|
|
2939
3126
|
state: props.state,
|
|
2940
|
-
permissionSetName: operation.permissionSetName
|
|
3127
|
+
permissionSetName: props.operation.permissionSetName
|
|
2941
3128
|
});
|
|
2942
3129
|
props.logger.log(
|
|
2943
|
-
`Updating IdC permission set session duration for "${operation.permissionSetName}"...`
|
|
3130
|
+
`Updating IdC permission set session duration for "${props.operation.permissionSetName}"...`
|
|
2944
3131
|
);
|
|
2945
3132
|
await props.ssoAdminClient.send(
|
|
2946
3133
|
new UpdatePermissionSetCommand({
|
|
2947
3134
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
2948
3135
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
2949
|
-
SessionDuration: operation.sessionDuration ?? void 0
|
|
3136
|
+
SessionDuration: props.operation.sessionDuration ?? void 0
|
|
2950
3137
|
})
|
|
2951
3138
|
);
|
|
2952
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3139
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
2953
3140
|
return upsertIdcPermissionSetInWorkingState({
|
|
2954
3141
|
workingState: props.state,
|
|
2955
3142
|
permissionSet: {
|
|
2956
3143
|
...permissionSet,
|
|
2957
|
-
sessionDuration: operation.sessionDuration
|
|
3144
|
+
sessionDuration: props.operation.sessionDuration
|
|
2958
3145
|
}
|
|
2959
3146
|
});
|
|
2960
3147
|
}
|
|
2961
|
-
if (operation.kind === "deleteIdcPermissionSet") {
|
|
3148
|
+
if (props.operation.kind === "deleteIdcPermissionSet") {
|
|
2962
3149
|
const permissionSet = resolvePermissionSetByName({
|
|
2963
3150
|
state: props.state,
|
|
2964
|
-
permissionSetName: operation.permissionSetName
|
|
3151
|
+
permissionSetName: props.operation.permissionSetName
|
|
2965
3152
|
});
|
|
2966
3153
|
props.logger.log(
|
|
2967
|
-
`Deleting IdC permission set "${operation.permissionSetName}"...`
|
|
3154
|
+
`Deleting IdC permission set "${props.operation.permissionSetName}"...`
|
|
2968
3155
|
);
|
|
2969
3156
|
await props.ssoAdminClient.send(
|
|
2970
3157
|
new DeletePermissionSetCommand({
|
|
@@ -2972,44 +3159,45 @@ async function executeOperation(props) {
|
|
|
2972
3159
|
PermissionSetArn: permissionSet.permissionSetArn
|
|
2973
3160
|
})
|
|
2974
3161
|
);
|
|
2975
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3162
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
2976
3163
|
return removeIdcPermissionSetFromWorkingState({
|
|
2977
3164
|
workingState: props.state,
|
|
2978
|
-
permissionSetName: operation.permissionSetName
|
|
3165
|
+
permissionSetName: props.operation.permissionSetName
|
|
2979
3166
|
});
|
|
2980
3167
|
}
|
|
2981
|
-
if (operation.kind === "putIdcPermissionSetInlinePolicy") {
|
|
3168
|
+
if (props.operation.kind === "putIdcPermissionSetInlinePolicy") {
|
|
3169
|
+
const { inlinePolicy } = props.operation;
|
|
2982
3170
|
const permissionSet = resolvePermissionSetByName({
|
|
2983
3171
|
state: props.state,
|
|
2984
|
-
permissionSetName: operation.permissionSetName
|
|
3172
|
+
permissionSetName: props.operation.permissionSetName
|
|
2985
3173
|
});
|
|
2986
3174
|
props.logger.log(
|
|
2987
|
-
`Putting inline policy on IdC permission set "${operation.permissionSetName}"...`
|
|
3175
|
+
`Putting inline policy on IdC permission set "${props.operation.permissionSetName}"...`
|
|
2988
3176
|
);
|
|
2989
3177
|
await props.ssoAdminClient.send(
|
|
2990
3178
|
new PutInlinePolicyToPermissionSetCommand({
|
|
2991
3179
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
2992
3180
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
2993
|
-
InlinePolicy:
|
|
3181
|
+
InlinePolicy: inlinePolicy
|
|
2994
3182
|
})
|
|
2995
3183
|
);
|
|
2996
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3184
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
2997
3185
|
return upsertPermissionSetPolicyState({
|
|
2998
3186
|
state: props.state,
|
|
2999
|
-
permissionSetName: operation.permissionSetName,
|
|
3187
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3000
3188
|
update: (currentPermissionSet) => ({
|
|
3001
3189
|
...currentPermissionSet,
|
|
3002
|
-
inlinePolicy
|
|
3190
|
+
inlinePolicy
|
|
3003
3191
|
})
|
|
3004
3192
|
});
|
|
3005
3193
|
}
|
|
3006
|
-
if (operation.kind === "deleteIdcPermissionSetInlinePolicy") {
|
|
3194
|
+
if (props.operation.kind === "deleteIdcPermissionSetInlinePolicy") {
|
|
3007
3195
|
const permissionSet = resolvePermissionSetByName({
|
|
3008
3196
|
state: props.state,
|
|
3009
|
-
permissionSetName: operation.permissionSetName
|
|
3197
|
+
permissionSetName: props.operation.permissionSetName
|
|
3010
3198
|
});
|
|
3011
3199
|
props.logger.log(
|
|
3012
|
-
`Deleting inline policy from IdC permission set "${operation.permissionSetName}"...`
|
|
3200
|
+
`Deleting inline policy from IdC permission set "${props.operation.permissionSetName}"...`
|
|
3013
3201
|
);
|
|
3014
3202
|
await props.ssoAdminClient.send(
|
|
3015
3203
|
new DeleteInlinePolicyFromPermissionSetCommand({
|
|
@@ -3017,154 +3205,158 @@ async function executeOperation(props) {
|
|
|
3017
3205
|
PermissionSetArn: permissionSet.permissionSetArn
|
|
3018
3206
|
})
|
|
3019
3207
|
);
|
|
3020
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3208
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3021
3209
|
return upsertPermissionSetPolicyState({
|
|
3022
3210
|
state: props.state,
|
|
3023
|
-
permissionSetName: operation.permissionSetName,
|
|
3211
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3024
3212
|
update: (currentPermissionSet) => ({
|
|
3025
3213
|
...currentPermissionSet,
|
|
3026
3214
|
inlinePolicy: null
|
|
3027
3215
|
})
|
|
3028
3216
|
});
|
|
3029
3217
|
}
|
|
3030
|
-
if (operation.kind === "attachIdcManagedPolicyToPermissionSet") {
|
|
3218
|
+
if (props.operation.kind === "attachIdcManagedPolicyToPermissionSet") {
|
|
3219
|
+
const { managedPolicyArn } = props.operation;
|
|
3031
3220
|
const permissionSet = resolvePermissionSetByName({
|
|
3032
3221
|
state: props.state,
|
|
3033
|
-
permissionSetName: operation.permissionSetName
|
|
3222
|
+
permissionSetName: props.operation.permissionSetName
|
|
3034
3223
|
});
|
|
3035
3224
|
props.logger.log(
|
|
3036
|
-
`Attaching managed policy "${
|
|
3225
|
+
`Attaching managed policy "${managedPolicyArn}" to IdC permission set "${props.operation.permissionSetName}"...`
|
|
3037
3226
|
);
|
|
3038
3227
|
await props.ssoAdminClient.send(
|
|
3039
3228
|
new AttachManagedPolicyToPermissionSetCommand({
|
|
3040
3229
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3041
3230
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3042
|
-
ManagedPolicyArn:
|
|
3231
|
+
ManagedPolicyArn: managedPolicyArn
|
|
3043
3232
|
})
|
|
3044
3233
|
);
|
|
3045
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3234
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3046
3235
|
return upsertPermissionSetPolicyState({
|
|
3047
3236
|
state: props.state,
|
|
3048
|
-
permissionSetName: operation.permissionSetName,
|
|
3237
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3049
3238
|
update: (currentPermissionSet) => ({
|
|
3050
3239
|
...currentPermissionSet,
|
|
3051
3240
|
awsManagedPolicies: [
|
|
3052
3241
|
...currentPermissionSet.awsManagedPolicies,
|
|
3053
|
-
|
|
3242
|
+
managedPolicyArn
|
|
3054
3243
|
]
|
|
3055
3244
|
})
|
|
3056
3245
|
});
|
|
3057
3246
|
}
|
|
3058
|
-
if (operation.kind === "detachIdcManagedPolicyFromPermissionSet") {
|
|
3247
|
+
if (props.operation.kind === "detachIdcManagedPolicyFromPermissionSet") {
|
|
3248
|
+
const { managedPolicyArn } = props.operation;
|
|
3059
3249
|
const permissionSet = resolvePermissionSetByName({
|
|
3060
3250
|
state: props.state,
|
|
3061
|
-
permissionSetName: operation.permissionSetName
|
|
3251
|
+
permissionSetName: props.operation.permissionSetName
|
|
3062
3252
|
});
|
|
3063
3253
|
props.logger.log(
|
|
3064
|
-
`Detaching managed policy "${
|
|
3254
|
+
`Detaching managed policy "${managedPolicyArn}" from IdC permission set "${props.operation.permissionSetName}"...`
|
|
3065
3255
|
);
|
|
3066
3256
|
await props.ssoAdminClient.send(
|
|
3067
3257
|
new DetachManagedPolicyFromPermissionSetCommand({
|
|
3068
3258
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3069
3259
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3070
|
-
ManagedPolicyArn:
|
|
3260
|
+
ManagedPolicyArn: managedPolicyArn
|
|
3071
3261
|
})
|
|
3072
3262
|
);
|
|
3073
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3263
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3074
3264
|
return upsertPermissionSetPolicyState({
|
|
3075
3265
|
state: props.state,
|
|
3076
|
-
permissionSetName: operation.permissionSetName,
|
|
3266
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3077
3267
|
update: (currentPermissionSet) => ({
|
|
3078
3268
|
...currentPermissionSet,
|
|
3079
3269
|
awsManagedPolicies: currentPermissionSet.awsManagedPolicies.filter(
|
|
3080
|
-
(
|
|
3270
|
+
(arn) => arn !== managedPolicyArn
|
|
3081
3271
|
)
|
|
3082
3272
|
})
|
|
3083
3273
|
});
|
|
3084
3274
|
}
|
|
3085
|
-
if (operation.kind === "attachIdcCustomerManagedPolicyReferenceToPermissionSet") {
|
|
3275
|
+
if (props.operation.kind === "attachIdcCustomerManagedPolicyReferenceToPermissionSet") {
|
|
3276
|
+
const { customerManagedPolicyName, customerManagedPolicyPath } = props.operation;
|
|
3086
3277
|
const permissionSet = resolvePermissionSetByName({
|
|
3087
3278
|
state: props.state,
|
|
3088
|
-
permissionSetName: operation.permissionSetName
|
|
3279
|
+
permissionSetName: props.operation.permissionSetName
|
|
3089
3280
|
});
|
|
3090
3281
|
props.logger.log(
|
|
3091
|
-
`Attaching customer-managed policy "${
|
|
3282
|
+
`Attaching customer-managed policy "${customerManagedPolicyPath}${customerManagedPolicyName}" to IdC permission set "${props.operation.permissionSetName}"...`
|
|
3092
3283
|
);
|
|
3093
3284
|
await props.ssoAdminClient.send(
|
|
3094
3285
|
new AttachCustomerManagedPolicyReferenceToPermissionSetCommand({
|
|
3095
3286
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3096
3287
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3097
3288
|
CustomerManagedPolicyReference: {
|
|
3098
|
-
Name:
|
|
3099
|
-
Path:
|
|
3289
|
+
Name: customerManagedPolicyName,
|
|
3290
|
+
Path: customerManagedPolicyPath
|
|
3100
3291
|
}
|
|
3101
3292
|
})
|
|
3102
3293
|
);
|
|
3103
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3294
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3104
3295
|
return upsertPermissionSetPolicyState({
|
|
3105
3296
|
state: props.state,
|
|
3106
|
-
permissionSetName: operation.permissionSetName,
|
|
3297
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3107
3298
|
update: (currentPermissionSet) => ({
|
|
3108
3299
|
...currentPermissionSet,
|
|
3109
3300
|
customerManagedPolicies: [
|
|
3110
3301
|
...currentPermissionSet.customerManagedPolicies,
|
|
3111
3302
|
{
|
|
3112
|
-
name:
|
|
3113
|
-
path:
|
|
3303
|
+
name: customerManagedPolicyName,
|
|
3304
|
+
path: customerManagedPolicyPath
|
|
3114
3305
|
}
|
|
3115
3306
|
]
|
|
3116
3307
|
})
|
|
3117
3308
|
});
|
|
3118
3309
|
}
|
|
3119
|
-
if (operation.kind === "detachIdcCustomerManagedPolicyReferenceFromPermissionSet") {
|
|
3310
|
+
if (props.operation.kind === "detachIdcCustomerManagedPolicyReferenceFromPermissionSet") {
|
|
3311
|
+
const { customerManagedPolicyName, customerManagedPolicyPath } = props.operation;
|
|
3120
3312
|
const permissionSet = resolvePermissionSetByName({
|
|
3121
3313
|
state: props.state,
|
|
3122
|
-
permissionSetName: operation.permissionSetName
|
|
3314
|
+
permissionSetName: props.operation.permissionSetName
|
|
3123
3315
|
});
|
|
3124
3316
|
props.logger.log(
|
|
3125
|
-
`Detaching customer-managed policy "${
|
|
3317
|
+
`Detaching customer-managed policy "${customerManagedPolicyPath}${customerManagedPolicyName}" from IdC permission set "${props.operation.permissionSetName}"...`
|
|
3126
3318
|
);
|
|
3127
3319
|
await props.ssoAdminClient.send(
|
|
3128
3320
|
new DetachCustomerManagedPolicyReferenceFromPermissionSetCommand({
|
|
3129
3321
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3130
3322
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3131
3323
|
CustomerManagedPolicyReference: {
|
|
3132
|
-
Name:
|
|
3133
|
-
Path:
|
|
3324
|
+
Name: customerManagedPolicyName,
|
|
3325
|
+
Path: customerManagedPolicyPath
|
|
3134
3326
|
}
|
|
3135
3327
|
})
|
|
3136
3328
|
);
|
|
3137
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3329
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3138
3330
|
return upsertPermissionSetPolicyState({
|
|
3139
3331
|
state: props.state,
|
|
3140
|
-
permissionSetName: operation.permissionSetName,
|
|
3332
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3141
3333
|
update: (currentPermissionSet) => ({
|
|
3142
3334
|
...currentPermissionSet,
|
|
3143
3335
|
customerManagedPolicies: currentPermissionSet.customerManagedPolicies.filter(
|
|
3144
|
-
(
|
|
3336
|
+
(policy) => policy.name !== customerManagedPolicyName || policy.path !== customerManagedPolicyPath
|
|
3145
3337
|
)
|
|
3146
3338
|
})
|
|
3147
3339
|
});
|
|
3148
3340
|
}
|
|
3149
|
-
if (operation.kind === "provisionIdcPermissionSet") {
|
|
3341
|
+
if (props.operation.kind === "provisionIdcPermissionSet") {
|
|
3150
3342
|
const permissionSet = resolvePermissionSetByName({
|
|
3151
3343
|
state: props.state,
|
|
3152
|
-
permissionSetName: operation.permissionSetName
|
|
3344
|
+
permissionSetName: props.operation.permissionSetName
|
|
3153
3345
|
});
|
|
3154
3346
|
props.logger.log(
|
|
3155
|
-
`Provisioning IdC permission set "${operation.permissionSetName}" to all provisioned accounts...`
|
|
3347
|
+
`Provisioning IdC permission set "${props.operation.permissionSetName}" to all provisioned accounts...`
|
|
3156
3348
|
);
|
|
3157
3349
|
const response = await props.ssoAdminClient.send(
|
|
3158
3350
|
new ProvisionPermissionSetCommand({
|
|
3159
3351
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3160
3352
|
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3161
|
-
TargetType: operation.targetScope
|
|
3353
|
+
TargetType: props.operation.targetScope
|
|
3162
3354
|
})
|
|
3163
3355
|
);
|
|
3164
3356
|
const requestId = response.PermissionSetProvisioningStatus?.RequestId ?? void 0;
|
|
3165
3357
|
if (requestId == null) {
|
|
3166
3358
|
throw new Error(
|
|
3167
|
-
`ProvisionPermissionSet for "${operation.permissionSetName}" returned no request id.`
|
|
3359
|
+
`ProvisionPermissionSet for "${props.operation.permissionSetName}" returned no request id.`
|
|
3168
3360
|
);
|
|
3169
3361
|
}
|
|
3170
3362
|
await waitForPermissionSetProvisioningSuccess({
|
|
@@ -3174,16 +3366,63 @@ async function executeOperation(props) {
|
|
|
3174
3366
|
requestId,
|
|
3175
3367
|
timeoutInMs: props.runtime.permissionSetProvisioning.timeoutInMs,
|
|
3176
3368
|
pollIntervalInMs: props.runtime.permissionSetProvisioning.pollIntervalInMs,
|
|
3177
|
-
operationLabel: `"${operation.permissionSetName}"`
|
|
3369
|
+
operationLabel: `"${props.operation.permissionSetName}"`
|
|
3178
3370
|
});
|
|
3179
|
-
props.logger.log(`Done: "${operation.permissionSetName}"`);
|
|
3371
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3180
3372
|
return props.state;
|
|
3181
3373
|
}
|
|
3182
|
-
if (operation.kind === "
|
|
3374
|
+
if (props.operation.kind === "putIdcPermissionSetPermissionsBoundary") {
|
|
3375
|
+
const permissionSet = resolvePermissionSetByName({
|
|
3376
|
+
state: props.state,
|
|
3377
|
+
permissionSetName: props.operation.permissionSetName
|
|
3378
|
+
});
|
|
3379
|
+
props.logger.log(
|
|
3380
|
+
`Putting permissions boundary on IdC permission set "${props.operation.permissionSetName}"...`
|
|
3381
|
+
);
|
|
3382
|
+
const boundary = props.operation.permissionsBoundary;
|
|
3383
|
+
await props.ssoAdminClient.send(
|
|
3384
|
+
new PutPermissionsBoundaryToPermissionSetCommand({
|
|
3385
|
+
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3386
|
+
PermissionSetArn: permissionSet.permissionSetArn,
|
|
3387
|
+
PermissionsBoundary: "managedPolicyArn" in boundary ? { ManagedPolicyArn: boundary.managedPolicyArn } : {
|
|
3388
|
+
CustomerManagedPolicyReference: {
|
|
3389
|
+
Name: boundary.customerManagedPolicyName,
|
|
3390
|
+
Path: boundary.customerManagedPolicyPath
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
})
|
|
3394
|
+
);
|
|
3395
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3396
|
+
return upsertIdcPermissionSetInWorkingState({
|
|
3397
|
+
workingState: props.state,
|
|
3398
|
+
permissionSet: { ...permissionSet, permissionsBoundary: boundary }
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
if (props.operation.kind === "deleteIdcPermissionSetPermissionsBoundary") {
|
|
3402
|
+
const permissionSet = resolvePermissionSetByName({
|
|
3403
|
+
state: props.state,
|
|
3404
|
+
permissionSetName: props.operation.permissionSetName
|
|
3405
|
+
});
|
|
3406
|
+
props.logger.log(
|
|
3407
|
+
`Deleting permissions boundary from IdC permission set "${props.operation.permissionSetName}"...`
|
|
3408
|
+
);
|
|
3409
|
+
await props.ssoAdminClient.send(
|
|
3410
|
+
new DeletePermissionsBoundaryFromPermissionSetCommand({
|
|
3411
|
+
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3412
|
+
PermissionSetArn: permissionSet.permissionSetArn
|
|
3413
|
+
})
|
|
3414
|
+
);
|
|
3415
|
+
props.logger.log(`Done: "${props.operation.permissionSetName}"`);
|
|
3416
|
+
return upsertIdcPermissionSetInWorkingState({
|
|
3417
|
+
workingState: props.state,
|
|
3418
|
+
permissionSet: { ...permissionSet, permissionsBoundary: null }
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
if (props.operation.kind === "removeIdcGroupMembership") {
|
|
3183
3422
|
const resolvedMembership = resolveGroupMembershipDependencies({
|
|
3184
3423
|
state: props.state,
|
|
3185
|
-
groupDisplayName: operation.groupDisplayName,
|
|
3186
|
-
userName: operation.userName
|
|
3424
|
+
groupDisplayName: props.operation.groupDisplayName,
|
|
3425
|
+
userName: props.operation.userName
|
|
3187
3426
|
});
|
|
3188
3427
|
const membershipId = await resolveGroupMembershipId({
|
|
3189
3428
|
state: props.state,
|
|
@@ -3192,7 +3431,7 @@ async function executeOperation(props) {
|
|
|
3192
3431
|
userId: resolvedMembership.userId
|
|
3193
3432
|
});
|
|
3194
3433
|
props.logger.log(
|
|
3195
|
-
`Removing user "${operation.userName}" from IdC group "${operation.groupDisplayName}"...`
|
|
3434
|
+
`Removing user "${props.operation.userName}" from IdC group "${props.operation.groupDisplayName}"...`
|
|
3196
3435
|
);
|
|
3197
3436
|
await props.identityStoreClient.send(
|
|
3198
3437
|
new DeleteGroupMembershipCommand({
|
|
@@ -3201,7 +3440,7 @@ async function executeOperation(props) {
|
|
|
3201
3440
|
})
|
|
3202
3441
|
);
|
|
3203
3442
|
props.logger.log(
|
|
3204
|
-
`Done: user "${operation.userName}" x group "${operation.groupDisplayName}"`
|
|
3443
|
+
`Done: user "${props.operation.userName}" x group "${props.operation.groupDisplayName}"`
|
|
3205
3444
|
);
|
|
3206
3445
|
return removeGroupMembershipFromWorkingState({
|
|
3207
3446
|
workingState: props.state,
|
|
@@ -3211,21 +3450,21 @@ async function executeOperation(props) {
|
|
|
3211
3450
|
}
|
|
3212
3451
|
});
|
|
3213
3452
|
}
|
|
3214
|
-
if (operation.kind === "grantIdcAccountAssignment") {
|
|
3453
|
+
if (props.operation.kind === "grantIdcAccountAssignment") {
|
|
3215
3454
|
const resolvedAssignment = resolveAssignmentDependencies({
|
|
3216
3455
|
state: props.state,
|
|
3217
|
-
accountName: operation.accountName,
|
|
3218
|
-
permissionSetName: operation.permissionSetName,
|
|
3219
|
-
principalType: operation.principalType,
|
|
3220
|
-
principalName: operation.principalName
|
|
3456
|
+
accountName: props.operation.accountName,
|
|
3457
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3458
|
+
principalType: props.operation.principalType,
|
|
3459
|
+
principalName: props.operation.principalName
|
|
3221
3460
|
});
|
|
3222
3461
|
props.logger.log(
|
|
3223
|
-
`Granting IdC assignment "${operation.permissionSetName}" to ${formatPrincipalLabel(
|
|
3462
|
+
`Granting IdC assignment "${props.operation.permissionSetName}" to ${formatPrincipalLabel(
|
|
3224
3463
|
{
|
|
3225
|
-
principalType: operation.principalType,
|
|
3226
|
-
principalName: operation.principalName
|
|
3464
|
+
principalType: props.operation.principalType,
|
|
3465
|
+
principalName: props.operation.principalName
|
|
3227
3466
|
}
|
|
3228
|
-
)} on "${operation.accountName}"...`
|
|
3467
|
+
)} on "${props.operation.accountName}"...`
|
|
3229
3468
|
);
|
|
3230
3469
|
const response = await props.ssoAdminClient.send(
|
|
3231
3470
|
new CreateAccountAssignmentCommand({
|
|
@@ -3240,7 +3479,7 @@ async function executeOperation(props) {
|
|
|
3240
3479
|
const requestId = response.AccountAssignmentCreationStatus?.RequestId;
|
|
3241
3480
|
if (requestId == null) {
|
|
3242
3481
|
throw new Error(
|
|
3243
|
-
`CreateAccountAssignment for "${operation.permissionSetName}" on "${operation.accountName}" returned no request id.`
|
|
3482
|
+
`CreateAccountAssignment for "${props.operation.permissionSetName}" on "${props.operation.accountName}" returned no request id.`
|
|
3244
3483
|
);
|
|
3245
3484
|
}
|
|
3246
3485
|
await waitForAccountAssignmentCreationSuccess({
|
|
@@ -3250,10 +3489,10 @@ async function executeOperation(props) {
|
|
|
3250
3489
|
requestId,
|
|
3251
3490
|
timeoutInMs: props.runtime.accountAssignment.timeoutInMs,
|
|
3252
3491
|
pollIntervalInMs: props.runtime.accountAssignment.pollIntervalInMs,
|
|
3253
|
-
operationLabel: `"${operation.permissionSetName}" on "${operation.accountName}"`
|
|
3492
|
+
operationLabel: `"${props.operation.permissionSetName}" on "${props.operation.accountName}"`
|
|
3254
3493
|
});
|
|
3255
3494
|
props.logger.log(
|
|
3256
|
-
`Done: "${operation.permissionSetName}" -> "${operation.accountName}"`
|
|
3495
|
+
`Done: "${props.operation.permissionSetName}" -> "${props.operation.accountName}"`
|
|
3257
3496
|
);
|
|
3258
3497
|
return addAccountAssignmentToWorkingState({
|
|
3259
3498
|
workingState: props.state,
|
|
@@ -3265,21 +3504,21 @@ async function executeOperation(props) {
|
|
|
3265
3504
|
}
|
|
3266
3505
|
});
|
|
3267
3506
|
}
|
|
3268
|
-
if (operation.kind === "revokeIdcAccountAssignment") {
|
|
3507
|
+
if (props.operation.kind === "revokeIdcAccountAssignment") {
|
|
3269
3508
|
const resolvedAssignment = resolveAssignmentDependencies({
|
|
3270
3509
|
state: props.state,
|
|
3271
|
-
accountName: operation.accountName,
|
|
3272
|
-
permissionSetName: operation.permissionSetName,
|
|
3273
|
-
principalType: operation.principalType,
|
|
3274
|
-
principalName: operation.principalName
|
|
3510
|
+
accountName: props.operation.accountName,
|
|
3511
|
+
permissionSetName: props.operation.permissionSetName,
|
|
3512
|
+
principalType: props.operation.principalType,
|
|
3513
|
+
principalName: props.operation.principalName
|
|
3275
3514
|
});
|
|
3276
3515
|
props.logger.log(
|
|
3277
|
-
`Revoking IdC assignment "${operation.permissionSetName}" from ${formatPrincipalLabel(
|
|
3516
|
+
`Revoking IdC assignment "${props.operation.permissionSetName}" from ${formatPrincipalLabel(
|
|
3278
3517
|
{
|
|
3279
|
-
principalType: operation.principalType,
|
|
3280
|
-
principalName: operation.principalName
|
|
3518
|
+
principalType: props.operation.principalType,
|
|
3519
|
+
principalName: props.operation.principalName
|
|
3281
3520
|
}
|
|
3282
|
-
)} on "${operation.accountName}"...`
|
|
3521
|
+
)} on "${props.operation.accountName}"...`
|
|
3283
3522
|
);
|
|
3284
3523
|
const response = await props.ssoAdminClient.send(
|
|
3285
3524
|
new DeleteAccountAssignmentCommand({
|
|
@@ -3294,7 +3533,7 @@ async function executeOperation(props) {
|
|
|
3294
3533
|
const requestId = response.AccountAssignmentDeletionStatus?.RequestId;
|
|
3295
3534
|
if (requestId == null) {
|
|
3296
3535
|
throw new Error(
|
|
3297
|
-
`DeleteAccountAssignment for "${operation.permissionSetName}" on "${operation.accountName}" returned no request id.`
|
|
3536
|
+
`DeleteAccountAssignment for "${props.operation.permissionSetName}" on "${props.operation.accountName}" returned no request id.`
|
|
3298
3537
|
);
|
|
3299
3538
|
}
|
|
3300
3539
|
await waitForAccountAssignmentDeletionSuccess({
|
|
@@ -3304,10 +3543,10 @@ async function executeOperation(props) {
|
|
|
3304
3543
|
requestId,
|
|
3305
3544
|
timeoutInMs: props.runtime.accountAssignment.timeoutInMs,
|
|
3306
3545
|
pollIntervalInMs: props.runtime.accountAssignment.pollIntervalInMs,
|
|
3307
|
-
operationLabel: `"${operation.permissionSetName}" on "${operation.accountName}"`
|
|
3546
|
+
operationLabel: `"${props.operation.permissionSetName}" on "${props.operation.accountName}"`
|
|
3308
3547
|
});
|
|
3309
3548
|
props.logger.log(
|
|
3310
|
-
`Done: "${operation.permissionSetName}" x "${operation.accountName}"`
|
|
3549
|
+
`Done: "${props.operation.permissionSetName}" x "${props.operation.accountName}"`
|
|
3311
3550
|
);
|
|
3312
3551
|
return removeAccountAssignmentFromWorkingState({
|
|
3313
3552
|
workingState: props.state,
|
|
@@ -3319,160 +3558,169 @@ async function executeOperation(props) {
|
|
|
3319
3558
|
}
|
|
3320
3559
|
});
|
|
3321
3560
|
}
|
|
3322
|
-
if (operation.kind === "createOrgPolicy") {
|
|
3561
|
+
if (props.operation.kind === "createOrgPolicy") {
|
|
3323
3562
|
props.logger.log(
|
|
3324
|
-
`Creating org policy "${operation.policyName}" (${operation.policyType})...`
|
|
3563
|
+
`Creating org policy "${props.operation.policyName}" (${props.operation.policyType})...`
|
|
3325
3564
|
);
|
|
3326
3565
|
const response = await props.organizationsClient.send(
|
|
3327
3566
|
new CreatePolicyCommand({
|
|
3328
|
-
Name: operation.policyName,
|
|
3329
|
-
Description: operation.description.length > 0 ? operation.description : void 0,
|
|
3330
|
-
Content: operation.content,
|
|
3331
|
-
Type: operation.policyType
|
|
3567
|
+
Name: props.operation.policyName,
|
|
3568
|
+
Description: props.operation.description.length > 0 ? props.operation.description : void 0,
|
|
3569
|
+
Content: props.operation.content,
|
|
3570
|
+
Type: props.operation.policyType
|
|
3332
3571
|
})
|
|
3333
3572
|
);
|
|
3334
3573
|
const policy = response.Policy?.PolicySummary;
|
|
3335
3574
|
if (policy?.Id == null || policy.Arn == null) {
|
|
3336
3575
|
throw new Error(
|
|
3337
|
-
`CreatePolicy for "${operation.policyName}" returned incomplete data.`
|
|
3576
|
+
`CreatePolicy for "${props.operation.policyName}" returned incomplete data.`
|
|
3338
3577
|
);
|
|
3339
3578
|
}
|
|
3340
|
-
props.logger.log(`Done: "${operation.policyName}"`);
|
|
3579
|
+
props.logger.log(`Done: "${props.operation.policyName}"`);
|
|
3341
3580
|
return upsertOrgPolicyInWorkingState({
|
|
3342
3581
|
workingState: props.state,
|
|
3343
3582
|
policy: {
|
|
3344
3583
|
id: policy.Id,
|
|
3345
3584
|
arn: policy.Arn,
|
|
3346
|
-
name: operation.policyName,
|
|
3347
|
-
description: operation.description,
|
|
3348
|
-
type: operation.policyType,
|
|
3349
|
-
content: operation.content
|
|
3585
|
+
name: props.operation.policyName,
|
|
3586
|
+
description: props.operation.description,
|
|
3587
|
+
type: props.operation.policyType,
|
|
3588
|
+
content: props.operation.content
|
|
3350
3589
|
}
|
|
3351
3590
|
});
|
|
3352
3591
|
}
|
|
3353
|
-
if (operation.kind === "updateOrgPolicyContent") {
|
|
3354
|
-
props.logger.log(
|
|
3592
|
+
if (props.operation.kind === "updateOrgPolicyContent") {
|
|
3593
|
+
props.logger.log(
|
|
3594
|
+
`Updating org policy content "${props.operation.policyName}"...`
|
|
3595
|
+
);
|
|
3355
3596
|
await props.organizationsClient.send(
|
|
3356
3597
|
new UpdatePolicyCommand({
|
|
3357
|
-
PolicyId: operation.policyId,
|
|
3358
|
-
Content: operation.content
|
|
3598
|
+
PolicyId: props.operation.policyId,
|
|
3599
|
+
Content: props.operation.content
|
|
3359
3600
|
})
|
|
3360
3601
|
);
|
|
3361
|
-
props.logger.log(`Done: "${operation.policyName}"`);
|
|
3362
|
-
const currentPolicy = props.state.organization.policiesById[operation.policyId];
|
|
3602
|
+
props.logger.log(`Done: "${props.operation.policyName}"`);
|
|
3603
|
+
const currentPolicy = props.state.organization.policiesById[props.operation.policyId];
|
|
3363
3604
|
if (currentPolicy == null) {
|
|
3364
3605
|
return props.state;
|
|
3365
3606
|
}
|
|
3366
3607
|
return upsertOrgPolicyInWorkingState({
|
|
3367
3608
|
workingState: props.state,
|
|
3368
|
-
policy: { ...currentPolicy, content: operation.content }
|
|
3609
|
+
policy: { ...currentPolicy, content: props.operation.content }
|
|
3369
3610
|
});
|
|
3370
3611
|
}
|
|
3371
|
-
if (operation.kind === "updateOrgPolicyDescription") {
|
|
3612
|
+
if (props.operation.kind === "updateOrgPolicyDescription") {
|
|
3372
3613
|
props.logger.log(
|
|
3373
|
-
`Updating org policy description "${operation.policyName}"...`
|
|
3614
|
+
`Updating org policy description "${props.operation.policyName}"...`
|
|
3374
3615
|
);
|
|
3375
3616
|
await props.organizationsClient.send(
|
|
3376
3617
|
new UpdatePolicyCommand({
|
|
3377
|
-
PolicyId: operation.policyId,
|
|
3378
|
-
Description: operation.description
|
|
3618
|
+
PolicyId: props.operation.policyId,
|
|
3619
|
+
Description: props.operation.description
|
|
3379
3620
|
})
|
|
3380
3621
|
);
|
|
3381
|
-
props.logger.log(`Done: "${operation.policyName}"`);
|
|
3382
|
-
const currentPolicy = props.state.organization.policiesById[operation.policyId];
|
|
3622
|
+
props.logger.log(`Done: "${props.operation.policyName}"`);
|
|
3623
|
+
const currentPolicy = props.state.organization.policiesById[props.operation.policyId];
|
|
3383
3624
|
if (currentPolicy == null) {
|
|
3384
3625
|
return props.state;
|
|
3385
3626
|
}
|
|
3386
3627
|
return upsertOrgPolicyInWorkingState({
|
|
3387
3628
|
workingState: props.state,
|
|
3388
|
-
policy: { ...currentPolicy, description: operation.description }
|
|
3629
|
+
policy: { ...currentPolicy, description: props.operation.description }
|
|
3389
3630
|
});
|
|
3390
3631
|
}
|
|
3391
|
-
if (operation.kind === "attachOrgPolicy") {
|
|
3632
|
+
if (props.operation.kind === "attachOrgPolicy") {
|
|
3392
3633
|
props.logger.log(
|
|
3393
|
-
`Attaching org policy "${operation.policyName}" to "${operation.targetName}"...`
|
|
3634
|
+
`Attaching org policy "${props.operation.policyName}" to "${props.operation.targetName}"...`
|
|
3394
3635
|
);
|
|
3395
3636
|
const resolvedPolicyId = resolvePolicyId({
|
|
3396
3637
|
state: props.state,
|
|
3397
|
-
policyId: operation.policyId,
|
|
3398
|
-
policyName: operation.policyName
|
|
3638
|
+
policyId: props.operation.policyId,
|
|
3639
|
+
policyName: props.operation.policyName
|
|
3399
3640
|
});
|
|
3400
3641
|
await props.organizationsClient.send(
|
|
3401
3642
|
new AttachPolicyCommand({
|
|
3402
3643
|
PolicyId: resolvedPolicyId,
|
|
3403
|
-
TargetId: operation.targetId
|
|
3644
|
+
TargetId: props.operation.targetId
|
|
3404
3645
|
})
|
|
3405
3646
|
);
|
|
3406
|
-
props.logger.log(
|
|
3407
|
-
|
|
3647
|
+
props.logger.log(
|
|
3648
|
+
`Done: "${props.operation.policyName}" -> "${props.operation.targetName}"`
|
|
3649
|
+
);
|
|
3650
|
+
const targetType = props.operation.targetId === props.context.organization.rootId ? "ROOT" : props.state.organization.organizationalUnitsById[props.operation.targetId] != null ? "ORGANIZATIONAL_UNIT" : "ACCOUNT";
|
|
3408
3651
|
return addOrgPolicyAttachmentToWorkingState({
|
|
3409
3652
|
workingState: props.state,
|
|
3410
3653
|
attachment: {
|
|
3411
3654
|
policyId: resolvedPolicyId,
|
|
3412
|
-
targetId: operation.targetId,
|
|
3655
|
+
targetId: props.operation.targetId,
|
|
3413
3656
|
targetType
|
|
3414
3657
|
}
|
|
3415
3658
|
});
|
|
3416
3659
|
}
|
|
3417
|
-
if (operation.kind === "detachOrgPolicy") {
|
|
3660
|
+
if (props.operation.kind === "detachOrgPolicy") {
|
|
3418
3661
|
props.logger.log(
|
|
3419
|
-
`Detaching org policy "${operation.policyName}" from "${operation.targetName}"...`
|
|
3662
|
+
`Detaching org policy "${props.operation.policyName}" from "${props.operation.targetName}"...`
|
|
3420
3663
|
);
|
|
3421
3664
|
await props.organizationsClient.send(
|
|
3422
3665
|
new DetachPolicyCommand({
|
|
3423
|
-
PolicyId: operation.policyId,
|
|
3424
|
-
TargetId: operation.targetId
|
|
3666
|
+
PolicyId: props.operation.policyId,
|
|
3667
|
+
TargetId: props.operation.targetId
|
|
3425
3668
|
})
|
|
3426
3669
|
);
|
|
3427
|
-
props.logger.log(
|
|
3670
|
+
props.logger.log(
|
|
3671
|
+
`Done: "${props.operation.policyName}" x "${props.operation.targetName}"`
|
|
3672
|
+
);
|
|
3428
3673
|
return removeOrgPolicyAttachmentFromWorkingState({
|
|
3429
3674
|
workingState: props.state,
|
|
3430
|
-
policyId: operation.policyId,
|
|
3431
|
-
targetId: operation.targetId
|
|
3675
|
+
policyId: props.operation.policyId,
|
|
3676
|
+
targetId: props.operation.targetId
|
|
3432
3677
|
});
|
|
3433
3678
|
}
|
|
3434
|
-
if (operation.kind === "deleteOrgPolicy") {
|
|
3435
|
-
props.logger.log(`Deleting org policy "${operation.policyName}"...`);
|
|
3679
|
+
if (props.operation.kind === "deleteOrgPolicy") {
|
|
3680
|
+
props.logger.log(`Deleting org policy "${props.operation.policyName}"...`);
|
|
3436
3681
|
await props.organizationsClient.send(
|
|
3437
|
-
new DeletePolicyCommand({ PolicyId: operation.policyId })
|
|
3682
|
+
new DeletePolicyCommand({ PolicyId: props.operation.policyId })
|
|
3438
3683
|
);
|
|
3439
|
-
props.logger.log(`Done: "${operation.policyName}"`);
|
|
3684
|
+
props.logger.log(`Done: "${props.operation.policyName}"`);
|
|
3440
3685
|
return removeOrgPolicyFromWorkingState({
|
|
3441
3686
|
workingState: props.state,
|
|
3442
|
-
policyId: operation.policyId
|
|
3687
|
+
policyId: props.operation.policyId
|
|
3443
3688
|
});
|
|
3444
3689
|
}
|
|
3445
|
-
if (operation.kind === "putAlternateContact") {
|
|
3690
|
+
if (props.operation.kind === "putAlternateContact") {
|
|
3691
|
+
const { contactType } = props.operation;
|
|
3446
3692
|
props.logger.log(
|
|
3447
|
-
`Setting ${
|
|
3693
|
+
`Setting ${contactType} alternate contact for "${props.operation.accountName}" (${props.operation.accountId})...`
|
|
3448
3694
|
);
|
|
3449
3695
|
await props.accountClient.send(
|
|
3450
3696
|
new PutAlternateContactCommand({
|
|
3451
|
-
AccountId: operation.accountId,
|
|
3452
|
-
AlternateContactType:
|
|
3453
|
-
Name: operation.name,
|
|
3454
|
-
EmailAddress: operation.email,
|
|
3455
|
-
PhoneNumber: operation.phone,
|
|
3456
|
-
Title: operation.title
|
|
3697
|
+
AccountId: props.operation.accountId,
|
|
3698
|
+
AlternateContactType: contactType,
|
|
3699
|
+
Name: props.operation.name,
|
|
3700
|
+
EmailAddress: props.operation.email,
|
|
3701
|
+
PhoneNumber: props.operation.phone,
|
|
3702
|
+
Title: props.operation.title
|
|
3457
3703
|
})
|
|
3458
3704
|
);
|
|
3459
|
-
props.logger.log(
|
|
3460
|
-
|
|
3705
|
+
props.logger.log(
|
|
3706
|
+
`Done: ${contactType} contact for "${props.operation.accountName}"`
|
|
3707
|
+
);
|
|
3708
|
+
const account = props.state.organization.accountsById[props.operation.accountId];
|
|
3461
3709
|
if (account == null) {
|
|
3462
3710
|
throw new Error(
|
|
3463
|
-
`Could not resolve account (${operation.accountId}) in working state.`
|
|
3711
|
+
`Could not resolve account (${props.operation.accountId}) in working state.`
|
|
3464
3712
|
);
|
|
3465
3713
|
}
|
|
3466
3714
|
const updatedContacts = [
|
|
3467
3715
|
...(account.alternateContacts ?? []).filter(
|
|
3468
|
-
(c) => c.contactType !==
|
|
3716
|
+
(c) => c.contactType !== contactType
|
|
3469
3717
|
),
|
|
3470
3718
|
{
|
|
3471
|
-
contactType
|
|
3472
|
-
name: operation.name,
|
|
3473
|
-
email: operation.email,
|
|
3474
|
-
phone: operation.phone,
|
|
3475
|
-
title: operation.title
|
|
3719
|
+
contactType,
|
|
3720
|
+
name: props.operation.name,
|
|
3721
|
+
email: props.operation.email,
|
|
3722
|
+
phone: props.operation.phone,
|
|
3723
|
+
title: props.operation.title
|
|
3476
3724
|
}
|
|
3477
3725
|
];
|
|
3478
3726
|
return upsertAccountInWorkingState({
|
|
@@ -3480,21 +3728,24 @@ async function executeOperation(props) {
|
|
|
3480
3728
|
account: { ...account, alternateContacts: updatedContacts }
|
|
3481
3729
|
});
|
|
3482
3730
|
}
|
|
3483
|
-
if (operation.kind === "deleteAlternateContact") {
|
|
3731
|
+
if (props.operation.kind === "deleteAlternateContact") {
|
|
3732
|
+
const { contactType } = props.operation;
|
|
3484
3733
|
props.logger.log(
|
|
3485
|
-
`Deleting ${
|
|
3734
|
+
`Deleting ${contactType} alternate contact for "${props.operation.accountName}" (${props.operation.accountId})...`
|
|
3486
3735
|
);
|
|
3487
3736
|
await props.accountClient.send(
|
|
3488
3737
|
new DeleteAlternateContactCommand({
|
|
3489
|
-
AccountId: operation.accountId,
|
|
3490
|
-
AlternateContactType:
|
|
3738
|
+
AccountId: props.operation.accountId,
|
|
3739
|
+
AlternateContactType: contactType
|
|
3491
3740
|
})
|
|
3492
3741
|
);
|
|
3493
|
-
props.logger.log(
|
|
3494
|
-
|
|
3742
|
+
props.logger.log(
|
|
3743
|
+
`Done: removed ${contactType} contact for "${props.operation.accountName}"`
|
|
3744
|
+
);
|
|
3745
|
+
const account = props.state.organization.accountsById[props.operation.accountId];
|
|
3495
3746
|
if (account == null) {
|
|
3496
3747
|
throw new Error(
|
|
3497
|
-
`Could not resolve account (${operation.accountId}) in working state.`
|
|
3748
|
+
`Could not resolve account (${props.operation.accountId}) in working state.`
|
|
3498
3749
|
);
|
|
3499
3750
|
}
|
|
3500
3751
|
return upsertAccountInWorkingState({
|
|
@@ -3502,20 +3753,20 @@ async function executeOperation(props) {
|
|
|
3502
3753
|
account: {
|
|
3503
3754
|
...account,
|
|
3504
3755
|
alternateContacts: (account.alternateContacts ?? []).filter(
|
|
3505
|
-
(c) => c.contactType !==
|
|
3756
|
+
(c) => c.contactType !== contactType
|
|
3506
3757
|
)
|
|
3507
3758
|
}
|
|
3508
3759
|
});
|
|
3509
3760
|
}
|
|
3510
|
-
if (operation.kind === "setIdcAccessControlAttributes") {
|
|
3761
|
+
if (props.operation.kind === "setIdcAccessControlAttributes") {
|
|
3511
3762
|
props.logger.log(
|
|
3512
|
-
`Setting IdC access control attributes (${operation.attributes.length} attribute(s))...`
|
|
3763
|
+
`Setting IdC access control attributes (${props.operation.attributes.length} attribute(s))...`
|
|
3513
3764
|
);
|
|
3514
3765
|
await props.ssoAdminClient.send(
|
|
3515
3766
|
new UpdateInstanceAccessControlAttributeConfigurationCommand({
|
|
3516
3767
|
InstanceArn: props.state.identityCenter.instanceArn,
|
|
3517
3768
|
InstanceAccessControlAttributeConfiguration: {
|
|
3518
|
-
AccessControlAttributes: operation.attributes.map((attr) => ({
|
|
3769
|
+
AccessControlAttributes: props.operation.attributes.map((attr) => ({
|
|
3519
3770
|
Key: attr.key,
|
|
3520
3771
|
Value: { Source: attr.source }
|
|
3521
3772
|
}))
|
|
@@ -3527,11 +3778,51 @@ async function executeOperation(props) {
|
|
|
3527
3778
|
...props.state,
|
|
3528
3779
|
identityCenter: {
|
|
3529
3780
|
...props.state.identityCenter,
|
|
3530
|
-
accessControlAttributes: operation.attributes
|
|
3781
|
+
accessControlAttributes: props.operation.attributes
|
|
3531
3782
|
}
|
|
3532
3783
|
};
|
|
3533
3784
|
}
|
|
3534
|
-
|
|
3785
|
+
if (props.operation.kind === "registerDelegatedAdministrator") {
|
|
3786
|
+
props.logger.log(
|
|
3787
|
+
`Registering delegated administrator "${props.operation.accountName}" (${props.operation.accountId}) for ${props.operation.servicePrincipal}...`
|
|
3788
|
+
);
|
|
3789
|
+
await props.organizationsClient.send(
|
|
3790
|
+
new RegisterDelegatedAdministratorCommand({
|
|
3791
|
+
AccountId: props.operation.accountId,
|
|
3792
|
+
ServicePrincipal: props.operation.servicePrincipal
|
|
3793
|
+
})
|
|
3794
|
+
);
|
|
3795
|
+
props.logger.log(
|
|
3796
|
+
`Done: "${props.operation.accountName}" for ${props.operation.servicePrincipal}`
|
|
3797
|
+
);
|
|
3798
|
+
return upsertDelegatedAdministratorInWorkingState({
|
|
3799
|
+
workingState: props.state,
|
|
3800
|
+
delegatedAdministrator: {
|
|
3801
|
+
accountId: props.operation.accountId,
|
|
3802
|
+
servicePrincipal: props.operation.servicePrincipal
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
}
|
|
3806
|
+
if (props.operation.kind === "deregisterDelegatedAdministrator") {
|
|
3807
|
+
props.logger.log(
|
|
3808
|
+
`Deregistering delegated administrator "${props.operation.accountName}" (${props.operation.accountId}) for ${props.operation.servicePrincipal}...`
|
|
3809
|
+
);
|
|
3810
|
+
await props.organizationsClient.send(
|
|
3811
|
+
new DeregisterDelegatedAdministratorCommand({
|
|
3812
|
+
AccountId: props.operation.accountId,
|
|
3813
|
+
ServicePrincipal: props.operation.servicePrincipal
|
|
3814
|
+
})
|
|
3815
|
+
);
|
|
3816
|
+
props.logger.log(
|
|
3817
|
+
`Done: removed "${props.operation.accountName}" for ${props.operation.servicePrincipal}`
|
|
3818
|
+
);
|
|
3819
|
+
return removeDelegatedAdministratorFromWorkingState({
|
|
3820
|
+
workingState: props.state,
|
|
3821
|
+
accountId: props.operation.accountId,
|
|
3822
|
+
servicePrincipal: props.operation.servicePrincipal
|
|
3823
|
+
});
|
|
3824
|
+
}
|
|
3825
|
+
assertUnreachable(props.operation, "Unsupported operation kind in apply.");
|
|
3535
3826
|
}
|
|
3536
3827
|
function resolveAssignmentDependencies(props) {
|
|
3537
3828
|
const account = props.state.organization.accountsByName[props.accountName];
|