Skip to content

Conversation

@paragor
Copy link

@paragor paragor commented Oct 16, 2025

Issue # 361

Closes # 361

Reason for this change

AWS RAM has restrictions that disallow issuing isCA: true certs from Subordinate AWS PCA.
see https://docs.aws.amazon.com/privateca/latest/userguide/UsingTemplates.html

However, for example, Linkerd requires such a certificate.

This pull request allows for requesting an issue certificate directly from AWS PCA that is located in a different account.

Description of changes

A new optional field 'role' was added to Issuer and ClusterIssuer CRDs, which allows assuming a role for another account and working with AWS PCA from a different account.

@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign sgtcodfish for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nickperry
Copy link

@paragor I think you might need to rebase now, since #430 was merged.

@bmsiegel bmsiegel force-pushed the assume_role_from_issuer_config branch from 9b40996 to ebfb00a Compare November 7, 2025 14:22
@cert-manager-prow cert-manager-prow bot added size/M and removed size/L labels Nov 7, 2025
@paragor
Copy link
Author

paragor commented Nov 7, 2025

@nickperry Hi, thank you for moving this topic forward. I’ll test my PR this weekend!

@bmsiegel
Copy link
Contributor

bmsiegel commented Nov 7, 2025

Just pushed a rebase to this PR. We will need to work on writing integration tests as well for this change since it's going to end up being a new support auth flow.

@paragor paragor force-pushed the assume_role_from_issuer_config branch 2 times, most recently from 6c1d47a to 9fe73ca Compare November 9, 2025 18:04
@paragor
Copy link
Author

paragor commented Nov 9, 2025

I’ve just renamed the attribute role -> roleArn. I have tested it locally, and everything looks good.
I’ll try to finish writing the integration tests this week. However, I’ll need help running them - the test run is expensive because it requires creating several AWS PCAs.

If anyone would like to pick up and complete the tests, feel free to do so.

@bmsiegel
Copy link
Contributor

bmsiegel commented Nov 10, 2025

I hate to do this, but can you change the role field back to just role? Cert-manager uses a role arn in one of its specs so we'd like to stay consistent with it:

apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: example
spec:
  acme:
    ...
    solvers:
    - dns01:
        route53:
          region: us-east-1
          role: <iam-role-arn> # This must be set so cert-manager what role to attempt to authenticate with
          auth:
            kubernetes:
              serviceAccountRef:
                name: <service-account-name> # The name of the service account created

source: https://cert-manager.io/docs/configuration/acme/dns01/route53/#cross-account-access

@nickperry
Copy link

I hate to do this, but can you change the role field back to just role?

Not my PR so I can't push to it, but I have implemented the name change requested by @bmsiegel here if you want to cherry-pick it nickperry@a670b1c

@bmsiegel bmsiegel force-pushed the assume_role_from_issuer_config branch 2 times, most recently from 491b75a to 270e8e7 Compare November 11, 2025 19:54
@cert-manager-prow cert-manager-prow bot added size/L and removed size/M labels Nov 11, 2025

func getIssuerSpecWithRole(caType string) v1beta1.AWSPCAIssuerSpec {
spec := getIssuerSpec(caType)
spec.Role = fmt.Sprintf("arn:%s:iam::%s:role/IssuerTestRole-%s-%s", testContext.partition, testContext.accountId, testContext.domain, testContext.region)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hard coding the name, can we make it default to "IssuerTestRole" but can be overridden by an environment variable? Alternatively, we could just take the whole role arn in as an environment variable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to do it with an environment variable, but then we couldn't run the testing before we merge it. What are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that we use an override and default to IssuerTestRole?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, default to IssuerTestRole but then allow you to override it for more flexibility

Comment on lines 126 to 132
// Match the complete resource: assumed-role/RoleName-DOMAIN-region/i-xxxxxxxxx
re := regexp.MustCompile(`^assumed-role/[^-]+-([^-]+)-[^/]+/i-[a-f0-9]+$`)
matches := re.FindStringSubmatch(parsedArn.Resource)
if len(matches) < 2 {
panic("Failed to extract domain from caller identity resource: " + parsedArn.Resource)
}
testContext.domain = matches[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to enforce this regex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? If the role is formatted incorrectly and we can't find the name, what should we do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, this regex just enforces the format of RoleName-domain-region. If we generalize it to just accept any role name, we don't need this regex and can remove the domain aspect right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we pair this with your other comment we can remove it. I was trying to make it domain safe. But this code was intended to pull it out for the tests

@bmsiegel bmsiegel force-pushed the assume_role_from_issuer_config branch 2 times, most recently from 045d91c to d2f851a Compare November 11, 2025 21:25
Signed-off-by: Egor Novikov <[email protected]>
Signed-off-by: Brady Siegel <[email protected]>
@bmsiegel bmsiegel force-pushed the assume_role_from_issuer_config branch from d2f851a to 901af13 Compare November 11, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants