コード例 #1
0
 public static async Task UpsertStack(
     string stackName, string templatePath, List <Parameter> parameters, List <Tag> tags, Credentials credentials, StackSettings settings = null)
 {
     if (await StackExists(stackName, credentials))
     {
         await UpdateStack(stackName, templatePath, parameters, tags, credentials, settings);
     }
     else
     {
         await CreateStack(stackName, templatePath, parameters, tags, credentials, settings);
     }
 }
コード例 #2
0
        public static async Task CreateStack(
            string stackName, string templatePath, List <Parameter> parameters, List <Tag> tags, Credentials credentials, StackSettings settings = null)
        {
            Console.WriteLine($"\nCreating stack {stackName}...");

            await GetClient(credentials).CreateStackAsync(
                new CreateStackRequest
            {
                StackName    = stackName,
                TemplateBody = File.ReadAllText(templatePath),
                Parameters   = parameters,
                Capabilities = new List <string> {
                    Capability.CAPABILITY_NAMED_IAM
                },
                Tags             = tags,
                DisableRollback  = true,
                NotificationARNs = settings?.NotificationArns?.ToList() ?? new List <string>()
            });

            await WaitForStackStatus(stackName, StackStatus.CREATE_COMPLETE, credentials);
        }
コード例 #3
0
        public static async Task UpdateStack(
            string stackName, string templatePath, List <Parameter> parameters, List <Tag> tags, Credentials credentials, StackSettings settings = null)
        {
            Console.WriteLine($"\nUpdating stack {stackName}...");

            try
            {
                await GetClient(credentials).UpdateStackAsync(
                    new UpdateStackRequest
                {
                    StackName    = stackName,
                    TemplateBody = File.ReadAllText(templatePath),
                    Parameters   = parameters,
                    Capabilities = new List <string> {
                        Capability.CAPABILITY_NAMED_IAM
                    },
                    Tags             = tags,
                    NotificationARNs = settings?.NotificationArns?.ToList() ?? new List <string>()
                });
            }
            catch (AmazonCloudFormationException exc) when(exc.Message == "No updates are to be performed.")
            {
                Console.WriteLine(exc.Message);

                return;
            }

            await WaitForStackStatus(stackName, StackStatus.UPDATE_COMPLETE, credentials);
        }