{fields.map(({ value, id, label, error }) => (
@@ -96,7 +205,6 @@ export const CspPolicyTemplateForm = memo
+
+ {/* AWS account type selection box */}
+ {input.type === 'cloudbeat/cis_aws' && (
+
+ )}
+
{/* Defines the name/description */}
= ({
enrollmentAPIKey,
cloudFormationTemplateUrl,
+ packagePolicy,
}) => {
const { isLoading, cloudFormationUrl, error, isError } = useCreateCloudFormationUrl({
enrollmentAPIKey,
cloudFormationTemplateUrl,
+ packagePolicy,
});
if (error && isError) {
diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/compute_steps.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/compute_steps.tsx
index fca803b8785a4..3977cdd5db576 100644
--- a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/compute_steps.tsx
+++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/compute_steps.tsx
@@ -254,6 +254,7 @@ export const ManagedSteps: React.FunctionComponent = ({
selectedApiKeyId,
enrollToken,
cloudFormationTemplateUrl,
+ agentPolicy,
})
);
} else {
diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/install_cloud_formation_managed_agent_step.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/install_cloud_formation_managed_agent_step.tsx
index b27a54d2149e2..75fec5be125f5 100644
--- a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/install_cloud_formation_managed_agent_step.tsx
+++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps/install_cloud_formation_managed_agent_step.tsx
@@ -11,9 +11,12 @@ import { i18n } from '@kbn/i18n';
import type { EuiContainedStepProps } from '@elastic/eui/src/components/steps/steps';
+import type { AgentPolicy } from '../../../../common';
+
import type { GetOneEnrollmentAPIKeyResponse } from '../../../../common/types/rest_spec/enrollment_api_key';
import { CloudFormationInstructions } from '../cloud_formation_instructions';
+import { FLEET_CLOUD_SECURITY_POSTURE_PACKAGE } from '../../../../common';
export const InstallCloudFormationManagedAgentStep = ({
selectedApiKeyId,
@@ -21,15 +24,22 @@ export const InstallCloudFormationManagedAgentStep = ({
enrollToken,
isComplete,
cloudFormationTemplateUrl,
+ agentPolicy,
}: {
selectedApiKeyId?: string;
apiKeyData?: GetOneEnrollmentAPIKeyResponse | null;
enrollToken?: string;
isComplete?: boolean;
cloudFormationTemplateUrl: string;
+ agentPolicy?: AgentPolicy;
}): EuiContainedStepProps => {
const nonCompleteStatus = selectedApiKeyId ? undefined : 'disabled';
const status = isComplete ? 'complete' : nonCompleteStatus;
+
+ const cloudSecurityPackagePolicy = agentPolicy?.package_policies?.find(
+ (p) => p.package?.name === FLEET_CLOUD_SECURITY_POSTURE_PACKAGE
+ );
+
return {
status,
title: i18n.translate('xpack.fleet.agentEnrollment.cloudFormation.stepEnrollAndRunAgentTitle', {
@@ -40,6 +50,7 @@ export const InstallCloudFormationManagedAgentStep = ({
) : (
diff --git a/x-pack/plugins/fleet/public/hooks/use_create_cloud_formation_url.ts b/x-pack/plugins/fleet/public/hooks/use_create_cloud_formation_url.ts
index cc76b68b6edb4..861217a272a32 100644
--- a/x-pack/plugins/fleet/public/hooks/use_create_cloud_formation_url.ts
+++ b/x-pack/plugins/fleet/public/hooks/use_create_cloud_formation_url.ts
@@ -7,20 +7,34 @@
import { i18n } from '@kbn/i18n';
+import type { PackagePolicy, PackagePolicyInput } from '../../common';
+
import { useKibanaVersion } from './use_kibana_version';
import { useGetSettings } from './use_request';
+type AwsAccountType = 'single_account' | 'organization_account';
+
+const CLOUDBEAT_AWS = 'cloudbeat/cis_aws';
+
+const getAwsAccountType = (input?: PackagePolicyInput): AwsAccountType | undefined =>
+ input?.streams[0].vars?.['aws.account_type'].value;
+
export const useCreateCloudFormationUrl = ({
enrollmentAPIKey,
cloudFormationTemplateUrl,
+ packagePolicy,
}: {
enrollmentAPIKey: string | undefined;
cloudFormationTemplateUrl: string;
+ packagePolicy?: PackagePolicy;
}) => {
const { data, isLoading } = useGetSettings();
const kibanaVersion = useKibanaVersion();
+ const awsInput = packagePolicy?.inputs?.find((input) => input.type === CLOUDBEAT_AWS);
+ const awsAccountType = getAwsAccountType(awsInput) || '';
+
let isError = false;
let error: string | undefined;
@@ -47,7 +61,8 @@ export const useCreateCloudFormationUrl = ({
cloudFormationTemplateUrl,
enrollmentAPIKey,
fleetServerHost,
- kibanaVersion
+ kibanaVersion,
+ awsAccountType
)
: undefined;
@@ -63,12 +78,19 @@ const createCloudFormationUrl = (
templateURL: string,
enrollmentToken: string,
fleetUrl: string,
- kibanaVersion: string
+ kibanaVersion: string,
+ awsAccountType: string
) => {
- const cloudFormationUrl = templateURL
+ let cloudFormationUrl;
+
+ cloudFormationUrl = templateURL
.replace('FLEET_ENROLLMENT_TOKEN', enrollmentToken)
.replace('FLEET_URL', fleetUrl)
.replace('KIBANA_VERSION', kibanaVersion);
+ if (cloudFormationUrl.includes('ACCOUNT_TYPE')) {
+ cloudFormationUrl = cloudFormationUrl.replace('ACCOUNT_TYPE', awsAccountType);
+ }
+
return new URL(cloudFormationUrl).toString();
};