Skip to content

Instantly share code, notes, and snippets.

@1oglop1
Last active July 23, 2021 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1oglop1/fb87b89636aebaeb5945863dbeca4ec3 to your computer and use it in GitHub Desktop.
Save 1oglop1/fb87b89636aebaeb5945863dbeca4ec3 to your computer and use it in GitHub Desktop.
"""A Python Pulumi program."""
import pulumi
import pulumi_aws.sns as sns
import pulumi
from pydantic import BaseModel
from pulumi import ComponentResource, ResourceOptions, Alias
class TopicModel(BaseModel):
name: str
class MyTopic(ComponentResource):
"""My SNS Topic"""
def __init__(self, config: TopicModel, opts: ResourceOptions = None):
super().__init__(
"my:components:aws:sns-topic",
config.name,
None,
opts,
)
self.topic = sns.Topic(
f"{config.name}-component_topic",
opts=ResourceOptions(
parent=self
)
)
self.register_outputs(
{
'component_topic_name': self.topic.name,
}
)
a = MyTopic(
config=TopicModel(
name='core-imported',
)
)
# Need to do this for every resource separately to get the Expected result.
pulumi.export('component_topic_name', a.topic.name)

Actual:

"resources": [
    {
        "urn": "urn:pulumi:core::prj-core::pulumi:pulumi:Stack::prj-core-core",
        "custom": false,
        "type": "pulumi:pulumi:Stack"
        ### Output is missing here
    },
    {
        "urn": "urn:pulumi:core::prj-core::stekz:components:aws:sns-topic::core-imported",
        "custom": false,
        "type": "stekz:components:aws:sns-topic",
        "outputs": {
            "component_topic_name": "core-imported-component_topic-c45a93a"
        },
        "parent": "urn:pulumi:core::prj-core::pulumi:pulumi:Stack::prj-core-core"
    },
]

Expected:

  "resources": [
      {
          "urn": "urn:pulumi:core::prj-core::pulumi:pulumi:Stack::prj-core-core",
          "custom": false,
          "type": "pulumi:pulumi:Stack",
          # Output is here but only after calling pulumi.export('component_topic_name', t.topic.name)
          "outputs": {
              "component_topic_name": "core-imported-component_topic-c45a93a"
          }
      },
      {
          "urn": "urn:pulumi:core::prj-core::stekz:components:aws:sns-topic::core-imported",
          "custom": false,
          "type": "stekz:components:aws:sns-topic",
          "outputs": {
              "component_topic_name": "core-imported-component_topic-c45a93a"
          },
          "parent": "urn:pulumi:core::prj-core::pulumi:pulumi:Stack::prj-core-core"
      },
  ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment