--- title_tag: "Getting Started with Automation API" meta_desc: This page contains a getting started guide for Automation API. title: Get started h1: Get started with Automation API weight: 1 meta_image: /images/docs/meta-images/docs-meta.png menu: usingpulumi: parent: automation-api aliases: - /docs/guides/automation-api/getting-started-automation-api/ --- Pulumi’s Automation API enables you to provision your infrastructure programmatically using the Pulumi engine by exposing Pulumi programs and stacks as strongly-typed and composable building blocks. In this guide, you will deploy an inline Pulumi program to create a static website using Automation API. ## Prerequisites ### Install Pulumi {{< install-pulumi />}} Install the required language runtime, if you have not already. ### Install language runtime #### Choose your language {{< chooser language "javascript,typescript,python,go,csharp" >}} {{% choosable language "javascript,typescript" %}} {{< install-node >}} {{% /choosable %}} {{% choosable language python %}} {{< install-python >}} {{% /choosable %}} {{% choosable language go %}} {{< install-go >}} {{% /choosable %}} {{% choosable language "csharp,fsharp,visualbasic" %}} {{< install-dotnet >}} {{% /choosable %}} {{< /chooser >}} ### Obtain a Pulumi access token You'll need a [Pulumi access token](/docs/pulumi-cloud/accounts#access-tokens) so that your programs can store the resulting state in the Pulumi Cloud. The easiest way to obtain a token is to run `pulumi login` from the command line. ## Define your Pulumi program {{< chooser language "javascript,typescript,python,go,csharp" >}} First, define the Pulumi program you want to run as a function within your overall program. Note how it looks like a standard Pulumi program. {{% choosable language "javascript,typescript" %}} {{% notes type="info" %}} This tutorial is based on the [`inlineProgram-ts` example](https://github.com/pulumi/automation-api-examples/tree/main/nodejs/inlineProgram-ts), which is a complete example of how to construct a simple Automation API program. {{% /notes %}} ```typescript const pulumiProgram = async () => { // Create a bucket and expose a website index document. const siteBucket = new s3.Bucket("s3-website-bucket", { website: { indexDocument: "index.html", }, }); const indexContent = `
Hello, world!
Made with ❤️ with Pulumi
` // Write our index.html into the site bucket. let object = new s3.BucketObject("index", { bucket: siteBucket, content: indexContent, contentType: "text/html; charset=utf-8", key: "index.html" }); // Create an S3 Bucket Policy to allow public read of all objects in bucket. function publicReadPolicyForBucket(bucketName): PolicyDocument { return { Version: "2012-10-17", Statement: [{ Effect: "Allow", Principal: "*", Action: [ "s3:GetObject" ], Resource: [ `arn:aws:s3:::${bucketName}/*` // Policy refers to bucket name explicitly. ] }] }; } // Set the access policy for the bucket so all objects are readable. let bucketPolicy = new s3.BucketPolicy("bucketPolicy", { bucket: siteBucket.bucket, // Refer to the bucket created earlier. policy: siteBucket.bucket.apply(publicReadPolicyForBucket) // Use output property `siteBucket.bucket`. }); return { websiteUrl: siteBucket.websiteEndpoint, }; }; ``` {{% /choosable %}} {{% choosable language python %}} {{% notes type="info" %}} This tutorial is based on the [`inline_program` example](https://github.com/pulumi/automation-api-examples/tree/main/python/inline_program), which is a complete example of how to construct a simple Automation API program. {{% /notes %}} ```python def pulumi_program(): # Create a bucket and expose a website index document. site_bucket = s3.Bucket("s3-website-bucket", website=s3.BucketWebsiteArgs(index_document="index.html")) index_content = """Hello, world!
Made with ❤️ with Pulumi
""" # Write our index.html into the site bucket. s3.BucketObject("index", bucket=site_bucket.id, # Reference to the s3.Bucket object. content=index_content, key="index.html", # Set the key of the object. content_type="text/html; charset=utf-8") # Set the MIME type of the file. # Set the access policy for the bucket so all objects are readable. s3.BucketPolicy("bucket-policy", bucket=site_bucket.id, policy={ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Principal": "*", "Action": ["s3:GetObject"], # Policy refers to bucket explicitly. "Resource": [pulumi.Output.concat("arn:aws:s3:::", site_bucket.id, "/*")] }, }) # Export the website URL. pulumi.export("website_url", site_bucket.website_endpoint) ``` {{% /choosable %}} {{% choosable language go %}} {{% notes type="info" %}} This tutorial is based on the [`inline_program` example](https://github.com/pulumi/automation-api-examples/tree/main/go/inline_program), which is a complete example of how to construct a simple Automation API program. {{% /notes %}} ```go deployFunc := func(ctx *pulumi.Context) error { // Similar go git_repo_program, our program defines a s3 website. // Here we create the bucket. siteBucket, err := s3.NewBucket(ctx, "s3-website-bucket", &s3.BucketArgs{ Website: s3.BucketWebsiteArgs{ IndexDocument: pulumi.String("index.html"), }, }) if err != nil { return err } // We define and upload our HTML inline. indexContent := `Hello, world!
Made with ❤️ with Pulumi
` // Upload our index.html. if _, err := s3.NewBucketObject(ctx, "index", &s3.BucketObjectArgs{ Bucket: siteBucket.ID(), // Reference to the s3.Bucket object. Content: pulumi.String(indexContent), Key: pulumi.String("index.html"), // Set the key of the object. ContentType: pulumi.String("text/html; charset=utf-8"), // Set the MIME type of the file. }); err != nil { return err } // Set the access policy for the bucket so all objects are readable. if _, err := s3.NewBucketPolicy(ctx, "bucketPolicy", &s3.BucketPolicyArgs{ Bucket: siteBucket.ID(), // Refer to the bucket created earlier. Policy: pulumi.Any(map[string]interface{}{ "Version": "2012-10-17", "Statement": []map[string]interface{}{ { "Effect": "Allow", "Principal": "*", "Action": []interface{}{ "s3:GetObject", }, "Resource": []interface{}{ pulumi.Sprintf("arn:aws:s3:::%s/*", siteBucket.ID()), // Policy refers to bucket name explicitly. }, }, }, }), }); err != nil { return err } // Export the website URL. ctx.Export("websiteUrl", siteBucket.WebsiteEndpoint) return nil } ``` {{% /choosable %}} {{< /chooser >}} {{% choosable language "csharp,fsharp,visualbasic" %}} {{% notes type="info" %}} This tutorial is based on the [`InlineProgram` example](https://github.com/pulumi/automation-api-examples/tree/main/dotnet/InlineProgram), which is a complete example of how to construct a simple Automation API program. {{% /notes %}} ```csharp var program = PulumiFn.Create(() => { // Create a bucket and expose a website index document. var siteBucket = new Pulumi.Aws.S3.Bucket( "s3-website-bucket", new Pulumi.Aws.S3.BucketArgs { Website = new Pulumi.Aws.S3.Inputs.BucketWebsiteArgs { IndexDocument = "index.html", }, }); const string indexContent = @"Hello, world!
Made with ❤️ with Pulumi
"; // Write our index.html into the site bucket. var @object = new Pulumi.Aws.S3.BucketObject( "index", new Pulumi.Aws.S3.BucketObjectArgs { Bucket = siteBucket.BucketName, // Reference to the s3 bucket object. Content = indexContent, Key = "index.html", // Set the key of the object. ContentType = "text/html; charset=utf-8", // Set the MIME type of the file. }); var bucketPolicyDocument = siteBucket.Arn.Apply(bucketArn => { return Output.Create(Pulumi.Aws.Iam.GetPolicyDocument.InvokeAsync( new Pulumi.Aws.Iam.GetPolicyDocumentArgs { Statements = new List