aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
188 stars 64 forks source link

Build failed Stack [CDKToolkit] already exists #1109

Closed seanaguinaga closed 9 months ago

seanaguinaga commented 9 months ago

Environment information

sean@Seans-MacBook-Pro src % npx amplify info
System:
  OS: macOS 14.3.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 10.23 GB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.11.1 - /opt/homebrew/opt/node@20/bin/node
  Yarn: 1.22.21 - /opt/homebrew/bin/yarn
  npm: 10.2.4 - /opt/homebrew/opt/node@20/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: Not Found
  @aws-amplify/backend-cli: Not Found
  aws-amplify: Not Found
  aws-cdk: Not Found
  aws-cdk-lib: Not Found
  typescript: Not Found
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
No CDK environment variables

Description

I am using the Web UI and this pops up even just using the demo github repo

Screenshot 2024-03-06 at 13 32 56
seanaguinaga commented 9 months ago
import { defineBackend } from '@aws-amplify/backend';
import { Duration } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as rds from 'aws-cdk-lib/aws-rds';
import { auth } from './auth/resource';
import { data } from './data/resource';

const backend = defineBackend({
  auth,
  data,
});

const customResourceStack = backend.createStack('CustomResourceStack');

// https://docs.amplify.aws/gen2/build-a-backend/add-aws-services/custom-resources/#adding-an-existing-cdk-construct
// Create an Aurora Serverless PostgreSQL database with default VPC
new rds.ServerlessCluster(customResourceStack, 'AuroraServerless', {
  engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
  scaling: { autoPause: Duration.hours(1) }, // Automatically pause after 1 hour of inactivity
  defaultDatabaseName: 'Pimary',
});

This is my backend.ts

seanaguinaga commented 9 months ago
Screenshot 2024-03-06 at 15 14 43

Under a different account with AmplifyBackendDeployFullAccess I get this