steep-alligator-79173
07/02/2020, 8:10 AMGet instance stack config
config_instance = pulumi.Config("instance")
config_instance = pulumi.Config("instance")
When I try to run tests I get:
ERROR: test_core_stack (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_core_stack
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/test_core_stack.py", line 13, in <module>
import core_stack
File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/core_stack.py", line 54, in <module>
instance_type=config_instance.require('bastion_size'),
File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/venv/lib/python3.7/site-packages/pulumi/config.py", line 214, in require
raise ConfigMissingError(self.full_key(key))
pulumi.config.ConfigMissingError: Missing required configuration variable 'instance:bastion_size'
please set a value using the command `pulumi config set instance:bastion_size <value>`
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
(venv)
How I can import configuration to tests ?stocky-lion-56153
07/02/2020, 10:19 AMpulumi stack select --create <stack name>
steep-alligator-79173
07/02/2020, 8:23 PM# Get az's for region
azs = aws.get_availability_zones(state="available")
Now when I try to run test :
File "/Users/unittests/infra.py", line 79, in <module>
for num, az in enumerate(azs.zone_ids):
TypeError: 'NoneType' object is not iterable
in Pulumi documentation i found:
call(token: string, args: any, provider?: undefined | string): Record<string, any>
call mocks provider-implemented function calls (e.g. aws.get_availability_zones).
But I have no idea how I can mock this call. For any code snippet I would be gratefulrhythmic-napkin-82334
07/04/2020, 6:16 PMflat-australia-79845
07/06/2020, 1:39 PM__pycache__
folders from the artifacts that I push to the cloud. Today I made this work in Pulumi with:
from fnmatch import fnmatch
from typing import Dict, Iterable, Union
from pathlib import Path
from pulumi.asset import Asset, Archive, AssetArchive, FileArchive, FileAsset
def filter_file_archive(
path: str, archive: FileArchive, exclude_patterns: Iterable[str] = None
) -> Dict[str, FileAsset]:
if not exclude_patterns:
exclude_patterns = []
file_iterator = Path(archive.path).rglob('*')
asset_root = Path(path)
assets = {
str(asset_root / file.relative_to(archive.path)): FileAsset(str(file))
for file in file_iterator if not any({fnmatch(file, pattern) for pattern in exclude_patterns})
}
return assets
class CodeAsset(AssetArchive):
def __init__(self, assets: Dict[str, Union[Asset, Archive]], exclude_patterns: Iterable[str] = None):
assets = self._filter_assets(assets, exclude_patterns)
super().__init__(assets=assets)
def _filter_assets(
self, assets: Dict[str, Union[Asset, Archive]], exclude_patterns: Iterable[str] = None
) -> Dict[str, Union[Asset, Archive]]:
filtered_assets: Dict[str, Union[Asset, Archive]] = {}
for path, asset in assets.items():
if isinstance(asset, FileArchive):
filtered_assets.update(filter_file_archive(path, asset, exclude_patterns))
else:
filtered_assets[path] = asset
return filtered_assets
then I use it this way:
archive = gcp.storage.BucketObject(
f'{function_name}-cloudfunction.zip',
bucket=bucket.name,
source=CodeAsset({
'.': pulumi.asset.FileArchive(str(source_folder / 'pairbot')),
'lib': pulumi.asset.FileArchive(str(source_folder / 'lib')),
}, exclude_patterns={'**/__pycache__*', '**/tests*'}),
)
swift-lunch-74411
07/07/2020, 2:41 PMswift-lunch-74411
07/07/2020, 3:00 PMbland-lamp-16797
07/09/2020, 3:10 PMclever-plumber-29709
07/09/2020, 8:13 PMastonishing-quill-88807
07/10/2020, 5:06 PMastonishing-quill-88807
07/10/2020, 5:06 PMcold-minister-39214
07/10/2020, 5:10 PMDiagnostics:
...
digitalocean:index:DnsRecord (a):
error: Preview failed: refreshing urn:pulumi:devjs::do-pulumi-node::digitalocean:index/dnsRecord:DnsRecord::a: domain is invalid because cannot be an empty string
I've confirmed that the ids used for import_ are correct with the digital ocean API. If I comment out the DnsRecord, I can import the domain with no problems. Any insight would be appreciated.billowy-laptop-45963
07/10/2020, 5:16 PMreturn pulumi.Output.all(bucket.bucket, obj.key).apply(
lambda args: f"<https://s3.amazonaws.com/{args[0]}/{args[1]}>"
)
mypy states:
Argument 1 to "all" of "Output" has incompatible type "Output[str]"; expected "Union[<nothing>, Awaitable[<nothing>], Output[<nothing>]]"
Argument 2 to "all" of "Output" has incompatible type "Output[str]"; expected "Union[<nothing>, Awaitable[<nothing>], Output[<nothing>]]"
Anyone see this before?stocky-lion-56153
07/11/2020, 12:42 PM__main__.py
please?
I have this pulumi.yaml
name: cli
main: infra/
runtime:
name: python
options:
virtualenv: ../venv
description: Flexiclock CLI
And these files
tree infra/
infra/
├── __init__.py
├── __main__.py
└── s3.py
stocky-lion-56153
07/11/2020, 12:43 PMfrom . import s3
in __main___.py
I get an error
ImportError: attempted relative import with no known parent package
salmon-gold-74709
07/13/2020, 7:41 AMquick-cricket-80200
07/13/2020, 10:26 PMlog_group = aws.cloudwatch.LogGroup("/ecs/log-group")
json = json.dumps([
{
"name": "app",
"image": "image",
"portMappings": [{
"containerPort": 8080,
"hostPort": 8080,
"protocol": "tcp"
}],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": log_group.name,
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
)
I am getting
TypeError: Object of type Output is not JSON serializable
sparse-state-34229
07/13/2020, 10:39 PMOutput.apply
gray-jewelry-3360
07/20/2020, 8:07 PMbetter-actor-92669
07/24/2020, 8:31 AMpulumi-postgresql
module that should have been fixed already. Can someone from Pulumi Team take a look please?
pulumi==2.7.1
pulumi-gcp==3.15.0
pulumi-kubernetes==2.4.0
pulumi-postgresql==2.2.2
pulumi-random==2.2.0
https://github.com/pulumi/pulumi-postgresql/issues/60brave-oyster-92747
07/24/2020, 3:58 PMbetter-actor-92669
07/27/2020, 2:30 PMpulumi new
if I already have it?
https://www.pulumi.com/docs/reference/cli/pulumi_new/
-g, --generate-only Generate the project only; do not create a stack, save config, or install dependencies
I need to create a stack, save config, I just need not to create the venv automaticallybright-policeman-55860
08/01/2020, 1:24 AMbright-policeman-55860
08/01/2020, 1:29 AMsubprocess.run(pulumi.Output.concat("whoami"))
bright-policeman-55860
08/02/2020, 12:43 PMdamp-elephant-82829
08/05/2020, 3:24 PMproud-queen-14294
08/06/2020, 6:18 PMdirectoryservice.Directory
If I copy and paste the python example here
I've made MINOR adjustments, but the issue still remains.
I get the following error:
Diagnostics:
aws:directoryservice:Directory (main):
error: InvalidParameterException: Invalid directory name. The directory name must be between 2 and 64 characters, and can only contain alphanumeric characters, periods (.). or minus signs (-). Also, the directory name must begin and end with an alphanumeric character. : RequestId: 362da74b-62dc-4116-8785-e65cbacb52c3
{
RespMetadata: {
StatusCode: 400,
RequestID: "362da74b-62dc-4116-8785-e65cbacb52c3"
},
Message_: "Invalid directory name. The directory name must be between 2 and 64 characters, and can only contain alphanumeric characters, periods (.). or minus signs (-). Also, the directory name must begin and end with an alphanumeric character. : RequestId: 362da74b-62dc-4116-8785-e65cbacb52c3",
RequestId: "362da74b-62dc-4116-8785-e65cbacb52c3"
}
pulumi:pulumi:Stack (training_workspaces-dev):
error: update failed
I've tried overwriting the name to avoid the generated hex code being added by using the name
parameter of Directory
, but it just gives the same error.
I find it odd that this is happening with example code from the docs.
Any ideas? Full code added as snippetwitty-ice-69000
08/08/2020, 2:10 PMpulumi --cwd <some dir>
is supposed to work.
I wanted to do something like this:
project root
|_ __main__.py
|_ bootstrap
|_ __main__.py
|_ core_deployment.py
|_ __init__.py
The bootstrap package has it's own __main__
file to establish the basic user, group and role for deployments and a privileged user must initially run pulumi --cwd bootstrap up
. Then for all other deployments, provided bootstrap doesn't need to change, then "regular" users can run pulumi up
and because the root __main__
always includes the bootstrap deployment, the state for the stack is always aligned and works just fine provided the regular user doesn't need to destroy the bootstrap state, and then a privileged user is needed again.
BUT using --cwd
results in the root __main__
being called regardless (the bootstrap __main__
is ignored). Even using cd bootstrap; pulumi up
still results in root __main__
being called.
What am I missing here?enough-ambulance-2841
08/10/2020, 4:00 PMaws.iam.get_policy_document
where I use the S3 bucket ARN in the policy, but it's simply not working (I think Pulumi doesn't know the dependency graph here). What is the best practice here? The docs lack examples that fit my use case ... My example: https://github.com/iserko/pulumi-test/blob/master/__main__.py#L33-L50proud-queen-14294
08/11/2020, 11:26 PMaws:workspaces:Workspace example creating error: workspace creation failed: The specified user could not be found in the directory.
when I specify the user_name
parameter, because the user doesn't exist, but I find no parameters in the directory or workspace interfaces that allow user creation.
EDIT: It appears it's part of the EC2 instance, very confused. The Workspaces GUI allows you to add users but I want to do that programatically
EDIT 2: Nevermind it seems it's a limitation of the AWS API, which seems silly in my opinion.. https://stackoverflow.com/questions/56995571/create-a-user-on-aws-workspaces-with-apiproud-queen-14294
08/11/2020, 11:26 PMaws:workspaces:Workspace example creating error: workspace creation failed: The specified user could not be found in the directory.
when I specify the user_name
parameter, because the user doesn't exist, but I find no parameters in the directory or workspace interfaces that allow user creation.
EDIT: It appears it's part of the EC2 instance, very confused. The Workspaces GUI allows you to add users but I want to do that programatically
EDIT 2: Nevermind it seems it's a limitation of the AWS API, which seems silly in my opinion.. https://stackoverflow.com/questions/56995571/create-a-user-on-aws-workspaces-with-api