everything I have for creating quicksight account:
const quicksightLambdaRole = new Role(this, "quicksightLambdaRole", {
assumedBy: new ServicePrincipal("lambda.amazonaws.com"),
});
quicksightLambdaRole.addToPolicy(
new PolicyStatement({
resources: ["*"],
effect: Effect.ALLOW,
actions: [
"quicksight:*",
"logs:*",
"iam:*",
"s3:*",
"athena:*",
"sso:*",
"lambda:*",
],
})
);
quicksightLambdaRole.addToPolicy(
new PolicyStatement({
resources: [`arn:aws:quicksight:us-east-1:${config.AWSAccountID}:*`],
effect: Effect.ALLOW,
actions: ["quicksight:CreateAccountSubscription"],
})
);
// create lambda that will create the quicksight account. It must have role attached
const qsApiName = "createQuickSightAccount";
const quicksightAccountLambda = new NodejsFunction(this, qsApiName, {
logRetention: 7,
entry: join(
__dirname,
"../lambdas/src/endpoints",
"createQuickSightAccount.ts"
),
...nodeJsFunctionProps,
environment: {
SF_HOST: config.sfHost,
},
runtime: Runtime.NODEJS_20_X,
role: quicksightLambdaRole,
timeout: Duration.minutes(5),
});
// add 'createQuickSightAccount' api to api gateway
const quicksightIntegration = new LambdaIntegration(
quicksightAccountLambda
);
const quicksightEntry = apiRoute.addResource(qsApiName);
quicksightEntry.addMethod("POST", quicksightIntegration);
addCorsOptions(quicksightEntry);
and my lambda function:
import { APIGatewayProxyHandler, APIGatewayProxyResult } from "aws-lambda";
import {
QuickSightClient,
CreateAccountSubscriptionCommand,
CreateAccountSubscriptionResponse,
CreateAccountSubscriptionRequest,
} from "@aws-sdk/client-quicksight"; // Update with actual types
export const handler: APIGatewayProxyHandler = async (
event
): Promise<APIGatewayProxyResult> => {
try {
console.log(event);
const client = new QuickSightClient({ region: "us-east-1" });
const command = new CreateAccountSubscriptionCommand({
Edition: "ENTERPRISE",
AuthenticationMethod: "IAM_AND_QUICKSIGHT",
AwsAccountId: "my account id",
AccountName: "my account name",
NotificationEmail: "my email",
EmailAddress: "my email",
});
// Use try-catch to handle errors
const response: CreateAccountSubscriptionResponse = await client.send(
command
);
console.log(response);
// Return a successful response
return {
statusCode: 200,
body: JSON.stringify(response), // or any other response format you prefer
};
} catch (error) {
// Return an error response
console.log(error);
return {
statusCode: 500,
body: JSON.stringify({ error: error.message }),
};
}
};
I am currently getting this specific error: The provided account name is not available. I entered a unique one So i dont think that is the actual issue