It's there any movement on <this> issue? It is qui...
# general
g
It's there any movement on this issue? It is quite easy to accidentally bring an app down. Quite scary that this is possible e.g. by adding additional permissions to a service running on ECS. This seems like quite basic functionality? Has anyone here running on ECS and deploying using Pulumi experienced this? Any workarounds at all?
s
Can you create the same policy twice so there's no shared attachment?
g
What do you mean? šŸ™‚
s
Is the policy doc: 1. Customer-managed and controlled by Pulumi 2. Customer-managed and one you are looking up e.g. via
.get()
3. An AWS-managed policy
g
Untitled.ts
This is basically my setup at the moment
I think at one point I had everything as an inline policy when creating the role, but then hit some AWS limit.
s
Side note: You might wanna move the inline policies to separate customer-managed policies because you can quickly hit a limit on IAM policy length.
Aha - you already hit that limit.
IDK if I'm misreading this, but it does not look like you're attaching the same policy to multiple roles here.
Are you definitely seeing buggy behavior? I'm not sure that the condition described in the bug is applicable here: The bug is talking about defining two Pulumi resources that attach the same policy to the same role. In this case, I think you're creating an IAM policy for each table, so that bug condition doesn't aoply.
g
Possible that the issue I've attached is not relevant, but I've definitely experienced bringing my app down a few times now due to Pulumi deleting policy attachments.
It's happened when doing something like adding a secret or adding a new policy. It's also happened after a refresh followed by a deployment.
s
Ok, that's definitely not good. Do you know any more details about under what conditions that outage happens? The most useful thing here would be the detailed diff (
details
) when
pulumi up
shows the preview.
Some of the resources involved might be
deleteBeforeReplace
by default.
g
The last time it happened (this morning), this was the order of events. Run pulumi refresh (shortened):
Copy code
~   │  └─ aws:ecs:Service                         blueberry                                                   updated (0.00s)     [diff: ~taskDefinition]
~   │  └─ aws:ecs:TaskDefinition                  blueberry                                                   updated (0.00s)     [diff: ~containerDefinitions]
~   ā”œā”€ aws:ec2:Eip                                shared-prod-eip-2                                           updated (1s)        [diff: ~associationId,instance,networkInterface,privateDns,privateIp]
~   ā”œā”€ aws:ec2:Eip                                shared-prod-eip-0                                           updated (1s)        [diff: ~associationId,instance,networkInterface,privateDns,privateIp]
 ~   ā”œā”€ docker-build:index:Image                   blueberry                                                   updated (5s)        [diff: ~contextHash]
 ~   ā”œā”€ aws:iam:Role                               blueberry-execution                                         updated (5s)        [diff: ~managedPolicyArns]
~   ā”œā”€ aws:ec2:Eip                                shared-prod-eip-1                                           updated (1s)        [diff: ~associationId,instance,networkInterface,privateDns,privateIp]

Resources:
    ~ 10 updated
    143 unchanged
Pulumi update (shortened):
Copy code
~   ā”œā”€ docker-build:index:Image       blueberry            updated          [diff: ~contextHash]
 ~   └─ aws:iam:Role                   blueberry-execution  updated (7s)     [diff: ~managedPolicyArns]

Outputs:
  - policyAttachments: [
  -     [0]: "arn:aws:iam::xxx:policy/kcl-production-xxx"
  -     [4]: "arn:aws:iam::xxx:policy/dynamodb-table-policy-production-xxx"
  -     [9]: "arn:aws:iam::xxx:policy/invoke-all-lambdas"
  -     [10]: "arn:aws:iam::xxx:policy/cognito-permissions"
    ]
  - serviceName      : "blueberry"
  - streamNames      : [
  -     [0]: "xxx-stream"
    ]
I think when there's a diff on
managedPolicyArns
it then proceeds to delete the attachments. The attachments then get recreated if I run
pulumi update
again.
Note: I did not edit the policies outside Pulumi.
s
Can you get the detailed diff next time you do an update? It'll show you exactly what attributes changed and from what to what. I don't see a recreate in there, so that'll probably not what's happening.
g
When I do an update, normally the only thing that changes is:
~   ā”œā”€ docker-build:index:Image       blueberry            updated          [diff: ~contextHash]
Can DM you the full diff if you like šŸ™‚ thanks for you help so far!
s
pulumi preview --diff
will give you the detailed diff. You can also select
details
when you run
pulumi up
to get the same output.
Unfortunately, unless you can spot the problematic pattern, we'll probably have to analyze the issue after a momentary outage.
g
This is quite easily reproducible by running refresh followed by an update
At which stage to you want me to run
pulumi preview --diff
? • Before running refresh • After running refresh, but before update 1 • After running update 1 (deletes attachments) • After running update 2 (recreates attachments)
Any chance we could hop on a call? šŸ™‚ Could probably reproduce it live in a dev environment