Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial impl of cloud.Bucket for azure. #545

Merged
merged 6 commits into from
Aug 13, 2018
Merged

Initial impl of cloud.Bucket for azure. #545

merged 6 commits into from
Aug 13, 2018

Conversation

CyrusNajmabadi
Copy link
Contributor

No description provided.

azure/bucket.ts Outdated
const preventDestroy = opts && opts.protect;

const resourceGroupName = shared.resourceGroupName;
const storageAccount = shared.getGlobalStorageAccount();
Copy link
Contributor Author

@CyrusNajmabadi CyrusNajmabadi Aug 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current design decisions:

  1. there is a global resource group that can also be specified by config. This is required. We could consider making it so if you don't provide one we create one for you.
  2. there is a global cloud infrastructure/storage account. You can specify the name of an existing storage account you want to use (using config). if not provided we will create a new one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider making it so if you don't provide one we create one for you.

Yes - I think we should do this. I expect the normal case here will be the user wants this to be it's own resource group.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. let me try that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Supplying a resource group is optional now. If you do, we'll use that. If you don't, we'll create a default one for you.

azure/bucket.ts Outdated
};

this.onDelete = async (delName, handler, filter) => {
throw new Error("Method not implemented.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: azure does not notify about blob deletes unless you use service-grid. I will file a bug on us adding support for this later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide a different error message here in the meantime - that this functionality isn't supported on in @pulumi/cloud-azure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.


const bucket = new cloud.Bucket("myBucket");
bucket.onPut("myPutHandler", async (args) => {
console.log(JSON.stringify(args, null, 2));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: logging to the console does not work. This is tracked over here: Azure/azure-functions-host#162

There's an open question on what we might want to do in pulumi to support this sort of thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use context.log which is supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. Remember, this is in the onPut callback. onPut simply passes data about the object that was put to the callback, there is no way to get to that context object here.

Now, we have some options:

  1. we could pass this context object along as another arg to the callback. This would be leaky, and would mean your code was now doing very azure specific stuff. I don't like this.
  2. we could attempt to intercept console events and then forward them to context.log ourself. I think this would work. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've gone with intercepting logging and just redirecting it to context logging.

constructor() {
super("cloud:global:infrastructure", "global-infrastructure");
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from @pulumi/aws. We could move it into @cloud/api, though i worry about this being visible in our public API.

Alternatively, we coudl maybe have a single file and symlink it to both projects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not immediately clear to me the same strategy will work for both AWS and Azure - Azure has very different name requirements. I think it's fine to allow this to be customized independently for each platform for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Will leave as a copy.

azure/shared.ts Outdated

const config = new pulumi.Config("cloud-azure");
export const resourceGroupName = config.require("resource-group-name");
export const location = config.require("location");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design decision: the default resource-group-name and location are required config properties we need at the cloud-azure level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on talkign to luke, this has been relxed. 'location' is still required (same as aws:regoin). However, resource-group can be elided. If so, we'll create a fresh "global" resource group on the behalf of the user.

return azure.storage.Account.get("global", storageAccountId);
}

return new azure.storage.Account("global", {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design decision: one can specify the storage account ot be used by default. if not specified, we will generate a global-infrastructure one for use in this package.

@CyrusNajmabadi
Copy link
Contributor Author

@lukehoban Ready for another review. Though i'll likely merge in this weekend unless you have any concerns.

@CyrusNajmabadi
Copy link
Contributor Author

@lukehoban Any other concerns?

@CyrusNajmabadi
Copy link
Contributor Author

Ok. Merging in. If you have any concerns let me know and i'll address them in a followup PR.

@CyrusNajmabadi CyrusNajmabadi merged commit 32225f5 into master Aug 13, 2018
@pulumi-bot pulumi-bot deleted the bucketImpl branch August 13, 2018 17:08
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants