Exemplo n.º 1
0
        internal MyAmplifyAppStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            // Get user, repo
            string      user  = StringParameter.ValueForStringParameter(this, "amplify-user");
            string      repo  = StringParameter.ValueForStringParameter(this, "amplify-repo");
            SecretValue token = SecretValue.SecretsManager("my-github-token");

            // The code that defines your stack goes here
            Amazon.CDK.AWS.Amplify.App amplifyApp = new Amazon.CDK.AWS.Amplify.App(this, "MyApp", new Amazon.CDK.AWS.Amplify.AppProps
            {
                SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps
                {
                    Owner      = user,
                    Repository = repo,
                    OauthToken = token
                }),
                BuildSpec = BuildSpec.FromObject(new Dictionary <string, object> { // Alternatively add a `amplify.yml` to the repo
                    { "version", "1.0" },
                    { "frontend", new Dictionary <string, object> {
                          { "Phases", new Dictionary <string, object> {
                                { "PreBuild", new Dictionary <string, object> {
                                    { "Commands", new [] { "yarn" } }
                                } },
                                { "Build", new Dictionary <string, object> {
                                    { "Commands", new [] { "yarn build" } }
                                } }
                            } },
                          { "Artifacts", new Dictionary <string, object> {
                                { "BaseDirectory", "public" },
                                { "Files", "**/*" }
                            } }
                      } }
                })
            });
        }
Exemplo n.º 2
0
        internal S2VXStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            var app = new Amplify.App(this, "S2VX", new Amplify.AppProps {
                // Configurations for Amplify to find and access our repo
                SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps {
                    Owner      = "maxrchung",
                    Repository = "S2VX",
                    OauthToken = SecretValue.PlainText(
                        // Personal access token generated for my GitHub account
                        System.Environment.GetEnvironmentVariable("PERSONAL_ACCESS_TOKEN")
                        )
                }),
            });

            // Links our s2vx.com domain to the repository branch
            var branch = app.AddBranch("release");
            var domain = app.AddDomain("s2vx.com");

            domain.MapRoot(branch);
        }