btp-setup-automator icon indicating copy to clipboard operation
btp-setup-automator copied to clipboard

[FEATURE REQUEST] Automate creation of sub-account within a directory

Open dachtera opened this issue 3 years ago • 7 comments
trafficstars

Which area is mainly impacted

Configuration

Requested Feature

I have not seen how to create a sub-account within a provided directory? We need to create sub-accounts within Customer directories (to help organize our efforts) and would prefer to not manually have to move sub-accounts once created with the automator.

196739346-90473bac-8e5d-47bb-8850-5428a318ec03

Preferred expectation using automator:

196739346-90473bac-8e5d-47bb-8850-5428a318ec03

Use Case/Scenario

This will allow the new sub-account to be created directly within a Customer space within the Global Account (our use case has a 3 sub accounts (dev, qa, preprod) for all customers to aid in organization, and distinct spaces for our different environments (and in some cases customer contractual requirements)

This will limit manual effort to go back in and manually move the newly created sub account from the root directory, to their designated space.

Would you like to support us?

  • [ ] Yes, I would like to support you

Anything else?

No response

dachtera avatar Oct 19 '22 19:10 dachtera

Tasks:

  • [X] Adjust JSON File for parameters to allow specification of directory and referencing of directory when defining subaccount
  • [X] Implement creations of directory if required and store mapping of name from parameters.json to ID after creation
  • [X] Enhance creation of subaccount to reference directory if specified (use mapping of name to id)

lechnerc77 avatar Oct 20 '22 09:10 lechnerc77

As the implementation might take a bit, you can use the "executeAfterAccountSetup" for directory creation and move of the subaccount under the directory to proceed with the automatic setup of the account. As the BTP CLI is available this would be the commands

lechnerc77 avatar Oct 21 '22 06:10 lechnerc77

Thank you - Is there a way to obtain the newly created subaccount and directory IDs to move the subaccount into the newly created directly within the automator process?

dachtera avatar Oct 21 '22 14:10 dachtera

The information is stored in the directory: /log as metadata_log.json in the container. The data is stored as JSON, yo you can access the subaccount ID via jq. The subaccountid can be fetched via:

jq '.subaccountid' ./log/metadata_log.json

You must fetch the directory ID via btp cli

lechnerc77 avatar Oct 21 '22 14:10 lechnerc77

OK Thanks You. I believe I have what I need to proceed.

dachtera avatar Oct 21 '22 14:10 dachtera

Reopening, as this is a valid request that should be available as part of the btpsa

lechnerc77 avatar Oct 22 '22 10:10 lechnerc77

Solution via PR #279 :

Basic configuration is done via usedirectory in parameters.json. This boolean parameter defines if a directory should be used/created when setting up the subaccount.

The following options exist for the further specification:

-no further parameters: A new directory is created; naming is derived by tool -specification of directoryname: a new directory is created using this name. If a directory with the same name exists, this will be taken -specification of directoryid (= existing directory): the corresponding directory will be used when the subaccount is created.

Restrictions:

  • you can only specify one directory and assign one subaccount to it
  • you can only specify a directory name when creating a new one
  • you cannot define nested structures (directory in directory)

To have the functionality fetch the latest version of the main branch of the repository or pull the latest Docker Image (sha sha256:254dc2c14918c45f7aed198ed4040748b0f433cb9e6aeec14becc53baf54e217)

lechnerc77 avatar Oct 25 '22 11:10 lechnerc77

I have not yet downloaded the new image, but I am seeing this when creating a new directory and sub-account.

I run the automator to create 1) the new directory (CustomerName) and 2) the subaccount (dev). Items are created as one would expect. Screen Shot 2022-10-25 at 7 16 13 AM

2nd, I manually move the newly created sub-account into the newly created directory. Screen Shot 2022-10-25 at 7 16 45 AM

3rd, I update the parameters file to change the Customer Name, and re-run the automator. However, there is no new sub-account created in the root of the Global Account, as I believe the system is still seeing the 1st sub-account tied to the root, and not moved into the CustomerName folder. Screen Shot 2022-10-25 at 7 49 04 AM

Is this expected behavior or an issue?

Our structure is laid out in a structure similar to this: Region --> Customer Name --> Connector Name --> Sub Account. (sub accounts will always have a 1-Dev, 2-QA, 3-PreProd (and if applicable 4-Prod) listings. Screen Shot 2022-10-25 at 8 21 30 AM

It appears we cannot retain our existing naming convention with the automator unless we're able to create the sub-account in the newly created folder, however I see that nesting is not allowed.

How many we overcome these issues while still retaining the use of the automator? Must we change to having a unique name such as appending a CustomerName prefix to all sub-accounts?

dachtera avatar Oct 25 '22 13:10 dachtera

Concerning your description: do you change the name of the subaccount that needs to be created? If not the tool will probably pick up the existing dev account as it does a matching via the name.

The scenarios you describe/target are currently not supported. I would recommend to motivate your organization to contribute to the tool, enhance its functionality in order to enable the support of your scenarios.

lechnerc77 avatar Oct 25 '22 13:10 lechnerc77

We would not change the name between customers, all would have a 1-Dev, 2-QA, 3-PreProd under their own directory. It seems our best course of action would be to prefix the sub-accounts with a customer identifier, as I am not a coder by profession, or able to support that role. Thank you.

dachtera avatar Oct 25 '22 14:10 dachtera

Quick question - you stated this: "If not the tool will probably pick up the existing dev account as it does a matching via the name."

So, even if the sub-account has been moved to a different sub-directory, the tool will still find that original (but moved) sub-account and re-use that instead of creating a new one in the root directory. If that is understood correctly, we will accommodate our naming convention. Thank You.

dachtera avatar Oct 25 '22 17:10 dachtera

Yes a different name will do the trick, as the tool (as well as the BTP CLI) fetches the subaccounts independent of their parent nodes (be it global account or a directory).

lechnerc77 avatar Oct 26 '22 04:10 lechnerc77