cdk migrate cannot deal with CDK Stacks

Abierto
#458 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
aws, typescript

Línea de trabajo

Empieza reproduciendo cdk migrate --from-stack --stack-name AppStack con el stack predeterminado de cdk init, incluidos ambos modos de informe de versiones. Inspecciona el TypeScript generado y el tratamiento de AWS::CDK::Metadata. Se considera terminado cuando la migración produce código sintácticamente válido, omite los metadatos de ruta de CDK y no incluye el parámetro BootstrapVersion.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug p1

cdk migrate --from-stack --stack-name AppStack

AppStack is the default stack as created by cdk init

First failure:

 ❌  Migrate failed for `AppStack`: AppStackStack could not be generated because Analytics is not a valid property for resource CDKMetadata of type AWS::CDK::Metadata

Deployed the stack again with --no-version-reporting. Then the migrate command works but generated code contains this (including syntax errors):

import * as cdk from 'aws-cdk-lib';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as sqs from 'aws-cdk-lib/aws-sqs';

export interface AppStackStackProps extends cdk.StackProps {
  /**
   * Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]
   * @default '/cdk-bootstrap/hnb659fds/version'
   */
  readonly bootstrapVersion?: string;
}

export class AppStackStack extends cdk.Stack {
  public constructor(scope: cdk.App, id: string, props: AppStackStackProps = {}) {
    super(scope, id, props);

    // Applying default props
    props = {
      ...props,
      bootstrapVersion: new cdk.CfnParameter(this, 'BootstrapVersion', {
        type: 'AWS::SSM::Parameter::Value<String>',
        default: props.bootstrapVersion?.toString() ?? '/cdk-bootstrap/hnb659fds/version',
        description: 'Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]',
      }).valueAsString,
    };

    // Resources
    const appQueueFd3f4958 = new sqs.CfnQueue(this, 'AppQueueFD3F4958', {
      visibilityTimeout: 300,
    });
    appQueueFd3f4958.cfnOptions.metadata = {
      aws:cdk:path: 'AppStack/AppQueue/Resource',
    };
    appQueueFd3f4958.cfnOptions.deletionPolicy = cdk.CfnDeletionPolicy.DELETE;

    const appTopic115Ea044 = new sns.CfnTopic(this, 'AppTopic115EA044', {
    });
    appTopic115Ea044.cfnOptions.metadata = {
      aws:cdk:path: 'AppStack/AppTopic/Resource',
    };

    const appQueuePolicyBd4f9387 = new sqs.CfnQueuePolicy(this, 'AppQueuePolicyBD4F9387', {
      policyDocument: {
        Statement: [
          {
            Action: 'sqs:SendMessage',
            Condition: {
              ArnEquals: {
                'aws:SourceArn': appTopic115Ea044.ref,
              },
            },
            Effect: 'Allow',
            Principal: {
              Service: 'sns.amazonaws.com',
            },
            Resource: appQueueFd3f4958.attrArn,
          },
        ],
        Version: '2012-10-17',
      },
      queues: [
        appQueueFd3f4958.ref,
      ],
    });
    appQueuePolicyBd4f9387.cfnOptions.metadata = {
      aws:cdk:path: 'AppStack/AppQueue/Policy/Resource',
    };

    const appQueueAppStackAppTopic352A2f0bba0ff351 = new sns.CfnSubscription(this, 'AppQueueAppStackAppTopic352A2F0BBA0FF351', {
      endpoint: appQueueFd3f4958.attrArn,
      protocol: 'sqs',
      topicArn: appTopic115Ea044.ref,
    });
    appQueueAppStackAppTopic352A2f0bba0ff351.cfnOptions.metadata = {
      aws:cdk:path: 'AppStack/AppQueue/AppStackAppTopic352A2F0B/Resource',
    };
    appQueueAppStackAppTopic352A2f0bba0ff351.addDependency(appQueuePolicyBd4f9387);
  }
}

Few things to note here:

A/ the generated code should not have syntax errors
B/ we should skip the CDK path metadata anyway
C/ we should probably not include the BootstrapVersion parameter

Lenguaje dominante
TypeScript
Estrellas
110
Forks
138
Merge medio
1 d 9 h
PR fusionados (30 d)
55

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws/aws-cdk-cli

Todos los issues de aws/aws-cdk-cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.