Check if Service Linked Role Already Exists #28981
-
We have a CDK project with several stacks, one of them is going to deploy OpenSearch and it needs "AWSServiceRoleForAmazonOpenSearchService" to exists before the actual resource being deployed.
So far this code works, but in the future we might be deploying it in regions that are not us-east-1 or ap-northeast-2 and this will break our code, or if the stack deployment is ap-northeast-2 first then us-east-1, this will also break the logic because the role will only be deployed us-east-1 but the stack will deploy OS domain in ap-northeast-2. The best logic is not to check based on the region, but based on role's existance
However, i dont see this mentioned in AWS CDK docs or other posts, is it possible, or is there another alternative method that will work? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is not mentioned in the AWS CDK documentation as it's not a native component of the CDK or AWS. upsert-slr is a 3rd party construct of the AWS CDK. Since upsert-slr is MIT and publicly available (https://github.com/tmokmss/upsert-slr/), you could take the code from there and implement this logic yourself - no sense in that - but then you have the same logic and no external dependencies. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
This is not mentioned in the AWS CDK documentation as it's not a native component of the CDK or AWS.
upsert-slr is a 3rd party construct of the AWS CDK.
These constructs are easy to use and extend the functionality of the CDK: They are reusable and save you time.
Since upsert-slr is MIT and publicly available (https://github.com/tmokmss/upsert-slr/), you could take the code from there and implement this logic yourself - no sense in that - but then you have the same logic and no external dependencies.