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 properties are not merged when doing a partial transform #4507

Closed
lukeshay opened this issue Jun 20, 2024 · 1 comment
Closed

Nested properties are not merged when doing a partial transform #4507

lukeshay opened this issue Jun 20, 2024 · 1 comment
Assignees

Comments

@lukeshay
Copy link
Contributor

When you pass a partial object to the transform field, the objects are not merged. For example, if you try to add an inline policy to a role, it does not get merged with the inline policies ion is adding. This is because the args and the transform object are spread and not merged. This line should do a deep merge and concat.

Example

sst.config.ts:

const table = new sst.aws.Table("Table");

// The inline policies array is overwritten so the policies that were added for the table are not there
new sst.aws.Function("Function", {
  link: [table],
  transform: {
    function: {
      tracingConfig: {
        mode: "Active",
      },
    },
    role: {
      inlinePolicies: [
        {
          name: "XRayPolicy",
          policy: $util.jsonStringify({
          Version: "2012-10-17",
            Statement: [
              {
                Effect: "Allow",
                Action: [
                  "xray:PutTraceSegments",
                  "xray:PutTelemetryRecords",
                ],
                Resource: "*",
              },
            ],
          }),
        },
      ],
    },
  },
});
@fwang
Copy link
Contributor

fwang commented Jul 28, 2024

hey @lukeshay

this should work:

new sst.aws.Function("Function", {
  transform: {
    role: (args) => {
      args.inlinePolicies.push({ ... });
    }
  }
});

i can see deep merge makes sense in this case, but it isn't ideal in other cases ie.

new sst.aws.Function("Function", {
  transform: {
    role: {
      architectures: ["arm64"]
    }
  }
});

the result architecture would've been both ["x86_64", "arm64"]

Feel free to reopen if u think current behavior isn't ideal.

@fwang fwang closed this as completed Jul 28, 2024
@thdxr thdxr transferred this issue from sst/ion Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants