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

Update ECS Service only when TaskDefinition is changed locally in pulumi #1982

Closed
ypresto opened this issue Feb 25, 2020 · 5 comments
Closed
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed

Comments

@ypresto
Copy link

ypresto commented Feb 25, 2020

I created ECS Service and initial TaskDefintion with pulumi, then I set up automatic deployment (creating new task definition and update service from CI).

In this configuration, how do I achieve both of 1 and 2?:

  1. When pulumi up without change, expects no change.
  2. When pulumi up with change on task definition, expects updating Service.

pulumi/pulumi-awsx#856 suggests ignoreChanges but it does not solve the second case.
Maybe we need to have ignoreChanges with function, to ignore only when updating revision is older than the state.

Current behavior of pulumi up after task def & service are updated by automatic deployment:

When I made NO changes to task def and without ignoreChanges

        ~ aws:ecs/service:Service: (update)
            [id=...]
            [urn=...]
            [provider=...]
          ~ taskDefinition: "arn:aws:ecs:ap-northeast-1:XXXXXXXXXXXX:task-definition/our-app-rails:5" => "arn:aws:ecs:ap-northeast-1:711533999350:task-definition/our-app-rails:4"

Pulumi is reverting task definition revision of service, even after pulumi refresh (Use Case of pulumi/pulumi-awsx#856)

When I made SOME changes to task def and with ignoreChanges (in transformations

     └─ awsx:x:ecs:FargateTaskDefinition  rails
 +-     └─ aws:ecs:TaskDefinition         rails           replace     [diff: ~containerDefinitions]

and no Service update.

@ypresto
Copy link
Author

ypresto commented Feb 26, 2020

Or can I configure pulumi to always reference the "latest" revision of a resource?

@leezen
Copy link
Contributor

leezen commented Feb 27, 2020

Could you please provide a working example of what you're doing? I tried to reproduce this behavior with a FargateTaskDefinition but my second pulumi up came back with no diff as expected.

@phillipedwards
Copy link
Member

This following code will reproduce the issue:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

let booleanItem: boolean | undefined;

const cluster = new aws.ecs.Cluster("diff-cluster");
const task = new aws.ecs.TaskDefinition("diff-task", {
    cpu: "256",
    memory: "512",
    requiresCompatibilities: ["FARGATE"],
    containerDefinitions: JSON.stringify([{
        name: "nginx-diff",
        image: "nginx",
        cpu: 256,
        portMappings: [{
            containerPort: 80
        }],
        environment: [
            {
                name: "name1",
                value: "this-value"
            },
            {
                name: "boolean-test",
                value: booleanItem // booleanItem ?? "" resolves the issue.
            }
        ]
    }]),
    networkMode: "awsvpc",
    family: "diff-task"
});

@mikhailshilkov
Copy link
Member

When I run the repro from @phillipedwards for the second time, this is the essence of the diff that I get:

                  ~ environment : [
                      + [1]: {
                              + name: "boolean-test"
                            }
                    ]

This means that the environment variable with an undefined value got ignored (makes sense) but now the provider calculates the difference as if it was meaningful.

I believe this is specific to the provider implementation, so I'll move the issue to pulumi-aws.

@mikhailshilkov mikhailshilkov transferred this issue from pulumi/pulumi May 30, 2022
@lukehoban lukehoban added kind/bug Some behavior is incorrect or out of spec awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). resolution/by-design This issue won't be fixed because the functionality is working as designed labels Nov 19, 2022
@lukehoban
Copy link
Member

This means that the environment variable with an undefined value got ignored (makes sense) but now the provider calculates the difference as if it was meaningful.

This is due to the design of the upstream provider diff implementation - which does some normalization on containerDefinitions, but does not normalize empty values. You must either leave off env vars that are undefined, or specify them with the empty string value. The request to handle this and similar issues more specifically in the upstream provider is hashicorp/terraform-provider-aws#11526.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

5 participants