diff --git a/backend/src/ee/services/pam-resource/aws-iam/aws-iam-resource-factory.ts b/backend/src/ee/services/pam-resource/aws-iam/aws-iam-resource-factory.ts index 01f593b4f..844908671 100644 --- a/backend/src/ee/services/pam-resource/aws-iam/aws-iam-resource-factory.ts +++ b/backend/src/ee/services/pam-resource/aws-iam/aws-iam-resource-factory.ts @@ -62,8 +62,7 @@ export const awsIamResourceFactory: TPamResourceFactory; -export const AwsIamAccountForm = ({ account, onSubmit }: Props) => { +export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmit }: Props) => { const isUpdate = Boolean(account); const { projectId } = useProject(); + const resourceIdToFetch = account?.resourceId || resourceId; + const resourceTypeToFetch = account?.resource?.resourceType || resourceType; + const { data: resource } = useGetPamResourceById(resourceTypeToFetch, resourceIdToFetch, { + enabled: !!resourceIdToFetch && !!resourceTypeToFetch + }); + + const pamRoleArn = + (resource?.resourceType === PamResourceType.AwsIam && + (resource as TAwsIamResource).connectionDetails?.roleArn) || + "arn:aws:iam:::role/"; + const targetRoleTrustPolicy = `{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { - "AWS": "arn:aws:iam:::role/" + "AWS": "${pamRoleArn}" }, "Action": "sts:AssumeRole", "Condition": { @@ -166,16 +182,12 @@ export const AwsIamAccountForm = ({ account, onSubmit }: Props) => {

- Note: Replace{" "} - <YOUR_ACCOUNT_ID> with - your AWS account ID and{" "} - <YOUR_PAM_ROLE_NAME>{" "} - with the name of the PAM role you created in the "Resources" tab. The - External ID{" "} + Note: The Principal role ARN shown above is from the PAM Resource + selected for this account. The External ID{" "} {projectId} is your - current project ID. If this target role name doesn't match the wildcard pattern - in your PAM role's permissions policy, you'll need to update that policy - to include this role's ARN. + current project ID. If your target role name doesn't match the wildcard pattern + in your PAM Resource's role's permissions policy, you'll need to + update that policy to include this role's ARN.

diff --git a/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx b/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx index 879167195..d9667ddbf 100644 --- a/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx +++ b/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx @@ -80,6 +80,8 @@ export const ResourceSelect = ({ onSubmit, projectId }: Props) => { return; } + // Clear search when a value is selected so the selected label is shown + setSearch(""); onChange(newValue); }} isLoading={isPending}