Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested stack validation incorrect #5029

Closed
jnieman opened this issue Nov 14, 2019 · 1 comment · Fixed by #4745
Closed

Nested stack validation incorrect #5029

jnieman opened this issue Nov 14, 2019 · 1 comment · Fixed by #4745
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@jnieman
Copy link

jnieman commented Nov 14, 2019

If I try to create a nested stack that deploys cross account, the error message should not give a regex stack name validation error message if the stack name matches the valid regex.

  1. Create custom construct class PipelineConstruct that creates a codepipeline pipeline.
  2. The pipeline should have a stage that contains the CloudFormationCreateReplaceChangeSetAction that deploys to a different account by specifying a different account in the account property of the action.
  3. Create stack class that initializes NestedStack and uses the stack class as the scope.
  4. Initialize PipelineConstruct and use the initialized nested stack as the scope.
  5. run cdk list
  6. receive regex stack name validation error message.
public class PipelinesApplication {

    public static void main(final String argv[]) {
        App app = new App();

        new PipelineStack(app, "PipelinesStack", StackProps.builder().env(Consts.Environments.SANDBOX).build());

        app.synth();
    }

    private static class PipelineStack extends Stack {

        public PipelineStack(final App parent, final String id, final StackProps props) {
            super(parent, id, props);

            String projectName = "SomeProject";

            NestedStack nestedStack = new NestedStack(this, projectName + "Stack");
            new PipelineConstruct(nestedStack, projectName + "PipelineProject", projectName);
        }

    }

    private static class PipelineConstruct extends Construct {

        public PipelineConstruct(final Construct scope, final String id, final String projectName) {
            super(scope, id);

            Pipeline pipeline2 = new Pipeline(this, "Pipeline",
                    PipelineProps.builder()
                            .pipelineName(projectName + "Pipeline")
                            .build());

            List<IAction> deployChangeSetActions = new ArrayList<>();
            ArtifactPath artifactPath = ArtifactPath.artifactPath("artifact", "template.yml");

            deployChangeSetActions.add(new CloudFormationCreateReplaceChangeSetAction(
                    CloudFormationCreateReplaceChangeSetActionProps.builder()
                            .actionName("Prepare-Change-Set")
                            .stackName(projectName + "stackName")
                            .changeSetName(projectName + "changeSetName")
                            .adminPermissions(true)
                            .templatePath(artifactPath)
                            .runOrder(3)
                            .account("123456789012")
                            .build()));

            pipeline2.addStage(StageOptions.builder()
                    .stageName("StageName")
                    .actions(deployChangeSetActions)
                    .build());

        }
        
    }

}

Error Log

Exception in thread "main" software.amazon.jsii.JsiiException: Stack name must match the regular expression: /^[A-Za-z][A-Za-z0-9-]*$/, got 'cross-account-support-stack-123456789012' Error: Stack name must match the regular expression: /^[A-Za-z][A-Za-z0-9-]*$/, got 'cross-account-support-stack-123456789012'

Environment

  • **CLI Version :**1.16.128
  • **Framework Version:**awscdk v1.15.0.DEVPREVIEW
  • **OS :**Mac
  • **Language :**Java 8

This is 🐛 Bug Report

@jnieman jnieman added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2019
@SomayaB SomayaB added the @aws-cdk/aws-codepipeline Related to AWS CodePipeline label Nov 15, 2019
@eladb
Copy link
Contributor

eladb commented Nov 17, 2019

Fixed by #4745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants