Amplify backend not linking up when amplify App created via CDK

0

Hey, so I thought (based on everything I've read/watched) that the CDK is very able to both create an amplify App and link the backend to other elements.

I can deploy my CDK app. It successfully creates a Cognito User Pool, S3, updates permissions and yes creates an Amplify App, which gets files from my Github repository.

However, the amplify app backend is not setup. If after the fact I try and use Amplify CLI and run Amplify init (either from my frontend code directory) or from my CDK project directory. It does not give the option to select the Amplify App already created by the CDK App, so I input the exact same App name, but it simply creates another Amplify App with the same name. This one will have the backend setup, based on the options I chose when using Amplify init.

Is this a bug, is there something else I need to add to my CDK Amplify stack code, as I was really trying to embrace the whole infrastructure with code approach, i.e. not do it separately via the Amplify CLI (not that that's helping anyway), plus don't want to setup via the console for the same reason.

Current code for my amplify stack... key details hidden with # : . (*The user pools are setup elsewhere)

`import * as cdk from 'aws-cdk-lib'; import * as amplify from '@aws-cdk/aws-amplify-alpha'; import { Construct } from 'constructs';

interface AmplifyStackProps extends cdk.StackProps { userPoolId: string; userPoolClientId: string; }

export class AmplifyStack extends cdk.Stack { constructor(scope: Construct, id: string, props: AmplifyStackProps) { super(scope, id, props);

const { userPoolId, userPoolClientId } = props;

const amplifyApp = new amplify.App(this, 'MyAmplifyApp', {
  sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
    owner: '##########',
    repository: '###########',
    oauthToken: cdk.SecretValue.secretsManager('###############'),
  }),
  environmentVariables: {
    USER_POOL_ID: userPoolId,
    USER_POOL_CLIENT_ID: userPoolClientId,
    APP_ID: 'cdk-generated-app-id' 
  },
});

new amplify.Branch(this, 'MyAmplifyAppBranch', {
  app: amplifyApp,
  branchName: 'main',
});

} }`

I assume I'm missing something key.

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions