Skip to content

[Bug]: SNS PlatformApplication import ID hard-codes GCM #2184

Description

@alexdor

Is there an existing issue for this?

  • I have searched the existing issues

Affected Resource(s)

  • sns.aws.m.upbound.io/v1beta1 - PlatformApplication

Resource MRs required to reproduce the bug

apiVersion: sns.aws.m.upbound.io/v1beta1
kind: PlatformApplication
metadata:
  name: example-ios-application
  annotations:
    # SNS application name, not ARN.
    crossplane.io/external-name: example-ios-application
spec:
  forProvider:
    region: eu-west-1
    platform: APNS_SANDBOX
    platformCredentialSecretRef:
      name: example-ios-credentials
      key: credential
    platformPrincipalSecretRef:
      name: example-ios-credentials
      key: principal

Steps to Reproduce

  1. Create an SNS PlatformApplication with platform: APNS or platform: APNS_SANDBOX.
  2. Configure the Crossplane MR external name as the SNS application name.
  3. Cause the provider to import the existing resource, for example by losing its local Terraform workspace during provider recovery.
  4. Observe the Terraform import ID generated from the external-name configuration.

What happened?

aws_sns_platform_application is configured in config/externalname.go as:

config.TemplatedStringAsIdentifier(
    "name",
    fullARNTemplate("sns", "app/GCM/{{ .external_name }}"),
)

This generates a GCM ARN for every PlatformApplication import, regardless of spec.forProvider.platform.

For an APNS_SANDBOX application named example-ios-application, the provider generates:

arn:aws:sns:<region>:<account-id>:app/GCM/example-ios-application

The required import ID is:

arn:aws:sns:<region>:<account-id>:app/APNS_SANDBOX/example-ios-application

Terraform imports SNS PlatformApplications using their ARN.

Relevant Error Output Snippet

Crossplane Version

2.3.4

Provider Version

2.6.0

Kubernetes Version

1.35.6

Kubernetes Distribution

EKS

Additional Info

Terraform documents ARN-based imports for SNS PlatformApplications:

https://github.com/hashicorp/terraform-provider-aws/blob/v5.100.0/website/docs/r/sns_platform_application.html.markdown#L80-L95

AWS documents GCM, APNS, and APNS_SANDBOX as valid platform values:

https://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformApplication.html

The import template should use the configured platform:

config.TemplatedStringAsIdentifier(
    "name",
    fullARNTemplate("sns", "app/{{ .parameters.platform }}/{{ .external_name }}"),
)

A previously proposed implementation exists in closed PR #1226

Separately, recovery after provider workspace state loss depends on Upjet selecting import rather than refresh/create for previously created async resources #562

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingis:triagedIndicates that an issue has been reviewed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions