Hi team, i am trying to get configuration from bel...
# general
Hi team, i am trying to get configuration from below template yaml. When i run pulumi up it's not picking the configuration and throwing a error like instancetype is not set main.py
Copy code
import pulumi
from pulumi_aws import ec2

# Define your Pulumi stack
class MyStack(pulumi.Stack):
    def __init__(self):

        # Get configuration values from Pulumi
        config = pulumi.Config()

        # Get necessary configuration values from Pulumi template.yaml
        instance_type = config.require("instanceType")
        ami = config.require("ami")

        # Create an AWS EC2 instance
        instance = ec2.Instance(
            tags={"Name": "MyInstance"},

        # Export the instance ID for reference
        self.instance_id = instance.id

# Create an instance of the stack
stack = MyStack()

# Export the instance ID
pulumi.export("instanceId", stack.instance_id)
Pulumi.template.yaml config: awsregion default: us-west-2 instanceType: description: "EC2 instance type" default: "t2.micro" ami: description: "AMI ID for the instance" default: "ami-12345678" # Replace with an appropriate AMI ID ``` Pulumi.yaml name: my-pulumi-project runtime: python description: My Pulumi Project
Can you try with
instead, which is needed for getting structured data from the config
Though there's a few things I'm unsure of in the code you've posted. Can you share the guide you're following please?
You have your configuration in a file named
, which would only be used if you had a Pulumi stack named “template”. Pulumi templates only work with
pulumi new
, so my advice to you would be… 1. Use
pulumi stack init
to create a stack. 2. Use
pulumi stack select <name>
to select the stack you just created. 3. Use
pulumi config set <key> <value>
to set the configuration values (like
pulumi config set instanceType t2.micro
). 4. Then run
pulumi up