diff --git a/python/azure/storage_account/.gitignore b/python/azure/storage_account/.gitignore new file mode 100644 index 00000000..a3807e5b --- /dev/null +++ b/python/azure/storage_account/.gitignore @@ -0,0 +1,2 @@ +*.pyc +venv/ diff --git a/python/azure/storage_account/Pulumi.yaml b/python/azure/storage_account/Pulumi.yaml new file mode 100644 index 00000000..e3790b75 --- /dev/null +++ b/python/azure/storage_account/Pulumi.yaml @@ -0,0 +1,6 @@ +name: azure_storage_account +runtime: + name: python + options: + virtualenv: venv +description: A minimal Azure Native Python Pulumi program diff --git a/python/azure/storage_account/__main__.py b/python/azure/storage_account/__main__.py new file mode 100644 index 00000000..2da262b8 --- /dev/null +++ b/python/azure/storage_account/__main__.py @@ -0,0 +1,52 @@ +"""An Azure RM Python Pulumi program""" + +import pulumi +import pulumi_azure as azure +from pulumi_azure_native import storage +from pulumi_azure_native import resources + +# Create an Azure Resource Group +resource_group = resources.ResourceGroup("resource_group") + +classic_account = azure.storage.Account( + "classic", + resource_group_name=resource_group.name, + account_tier="Standard", + account_kind="BlobStorage", + access_tier="Hot", + account_replication_type="RAGRS", +) + +pulumi.export("classic_connection_string", classic_account.primary_connection_string) + +# # Create an Azure resource (Storage Account) +account = storage.StorageAccount( + "account", + resource_group_name=resource_group.name, + sku=storage.SkuArgs( + name=storage.SkuName.STANDARD_LRS, + ), + kind=storage.Kind.STORAGE_V2, +) + +""" +The primary connection string is not an API response from the ARM API +We can use the actual API responses to form the connection string +""" +def get_connection_string(resource_group_name: pulumi.Output[str], account_name: pulumi.Output[str]) -> pulumi.Output[str]: + keys = storage.list_storage_account_keys_output(resource_group_name=resource_group_name, account_name=account_name) + """ + This is a secret because it contains the storage account key + """ + return pulumi.Output.secret(pulumi.Output.format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix=core.windows.net", account_name, keys.keys[0].value)) + +pulumi.export("native_connnection_string", get_connection_string(resource_group.name, account.name)) + +# # Export the primary key of the Storage Account +# primary_key = pulumi.Output.all(resource_group.name, account.name) \ +# .apply(lambda args: storage.list_storage_account_keys( +# resource_group_name=args[0], +# account_name=args[1] +# )).apply(lambda accountKeys: accountKeys.keys[0].value) + +# pulumi.export("primary_storage_key", primary_key) diff --git a/python/azure/storage_account/requirements.txt b/python/azure/storage_account/requirements.txt new file mode 100644 index 00000000..d77b5a35 --- /dev/null +++ b/python/azure/storage_account/requirements.txt @@ -0,0 +1,2 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-azure-native>=1.0.0,<2.0.0 diff --git a/terraform/eks/index.ts b/terraform/eks/index.ts deleted file mode 100644 index 7cfffbd4..00000000 --- a/terraform/eks/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; - -const exampleCluster = aws.eks.getCluster({ - name: "lbriggs-eksCluster-04570ef", -}); -const exampleClusterAuth = aws.eks.getClusterAuth({ - name: "lbriggs-eksCluster-04570ef", -}); -export const clusterId = exampleClusterAuth.then(exampleClusterAuth => exampleClusterAuth.id); -export const clusterToken = exampleClusterAuth.then(exampleClusterAuth => exampleClusterAuth.token); diff --git a/terraform/eks/main.tf b/terraform/eks/main.tf deleted file mode 100644 index 9c90869d..00000000 --- a/terraform/eks/main.tf +++ /dev/null @@ -1,16 +0,0 @@ -data "aws_eks_cluster" "example" { - name = "lbriggs-eksCluster-04570ef" -} - -data "aws_eks_cluster_auth" "example" { - name = "lbriggs-eksCluster-04570ef" -} - -output "cluster_id" { - value = data.aws_eks_cluster_auth.example.id -} - -output "cluster_token" { - value = data.aws_eks_cluster_auth.example.token - sensitive = true -} diff --git a/terraform/eks/providers.tf b/terraform/eks/providers.tf deleted file mode 100644 index 81e31c86..00000000 --- a/terraform/eks/providers.tf +++ /dev/null @@ -1,14 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 3.27" - } - } - - required_version = ">= 0.14.9" -} - -provider "aws" { - region = "us-west-2" -}