morning - anyone used pulumi_onepassword provider...
# python
b
morning - anyone used pulumi_onepassword provider. It is giving me the run around on passing credentials to it. the documentation is lacking and LLMs including pulumi's arent getting it right
m
Can you show a minimal code example that illustrates your problem?
b
Copy code
import pulumi
import pulumi_aws as aws
import pulumi_onepassword as onepassword

# 1. Configure the 1Password Provider
provider_args = pulumi.ProviderResourceArgs.create(
    onepassword=onepassword.ProviderArgs(
        service_account_token=pulumi.get_secret("op_service_account_token"), 
    )
)

# 2. Fetch the Secret from 1Password
my_secret = onepassword.get_item(
    "my_secret",
    args=onepassword.GetItemArgs(
        vault="my_vault",
        uuid="my_secret_uuid",  # Replace with the actual UUID of your 1Password secret
    ),
    opts=pulumi.ResourceOptions(providers={"onepassword": provider_args}),
)

# 3. Use the Secret to Create an AWS Resource
# Example: Create an AWS IAM User with a programmatically generated password
iam_user = aws.iam.User("my_user")

iam_user_login_profile = aws.iam.UserLoginProfile(
    "my_user_login_profile",
    user=iam_user.name,
    password=my_secret.fields["password"].apply(lambda secret: secret), 
)

# 4. Output the IAM User's ARN
pulumi.export("iam_user_arn", iam_user.arn)
this was generated from good ol gemini but it has lots of mistakes
m
I suggest you start by providing the token as an environment variable
OP_SERVICE_ACCOUNT_TOKEN
, figure out the 1Password request, and worry about how to manage/persist the 1Password credentials later