Last active
August 12, 2022 09:51
-
-
Save sanju2/042efb3fad18272b326dd985e1690951 to your computer and use it in GitHub Desktop.
Automate Building AWS S3 Bucket on AWS with CDK for Terraform Article Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from constructs import Construct | |
from cdktf import App, NamedRemoteWorkspace, TerraformStack, TerraformOutput, RemoteBackend | |
from cdktf_cdktf_provider_aws import AwsProvider, s3 | |
class MyStack(TerraformStack): | |
def __init__(self, scope: Construct, ns: str): | |
super().__init__(scope, ns) | |
AwsProvider(self, "AWS", region="{{region}}") | |
first_bucket = s3.S3Bucket( | |
self, "cdktf-s3-static-web", | |
bucket="{{bucket-name/use-unique-name}}" | |
) | |
TerraformOutput(self, "bucket_name", value=first_bucket.bucket) | |
TerraformOutput(self, "bucket_arn", value=first_bucket.arn) | |
app = App() | |
stack = MyStack(app, "cdktf-s3-static-web") | |
RemoteBackend(stack, | |
hostname='app.terraform.io', | |
organization='{{terraform-cloud-organization-name}}', | |
workspaces=NamedRemoteWorkspace('{{terraform-cloud-workspace-name}}') | |
) | |
app.synth() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment