-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add construct for credentials and pack under main stack
- Loading branch information
Yuriy Bezsonov
committed
Jan 7, 2024
1 parent
c88e7ac
commit 9fb1b55
Showing
4 changed files
with
73 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
lib/workloads-codecommit-construct/codecommit-credentials.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, PhysicalResourceIdReference } from 'aws-cdk-lib/custom-resources'; | ||
import { Construct } from 'constructs'; | ||
|
||
export class CodeCommitCredentials extends Construct { | ||
readonly serviceSpecificCredentialId: string; | ||
readonly serviceName: string; | ||
readonly serviceUserName: string; | ||
readonly servicePassword: string; | ||
readonly status: string; | ||
|
||
constructor(scope: Construct, id: string, userName: string) { | ||
super(scope, id); | ||
|
||
const codeCommitCredentialsResponse = new AwsCustomResource(this, "codecommit-credentials-custom-resource", { | ||
onCreate: { | ||
service: "IAM", | ||
action: "createServiceSpecificCredential", | ||
parameters: { | ||
ServiceName: "codecommit.amazonaws.com", | ||
UserName: userName | ||
}, | ||
physicalResourceId: PhysicalResourceId.fromResponse("ServiceSpecificCredential.ServiceSpecificCredentialId") | ||
}, | ||
onDelete: { | ||
service: "IAM", | ||
action: "deleteServiceSpecificCredential", | ||
parameters: { | ||
ServiceSpecificCredentialId: new PhysicalResourceIdReference(), | ||
UserName: userName, | ||
} | ||
}, | ||
policy: AwsCustomResourcePolicy.fromSdkCalls({ | ||
resources: AwsCustomResourcePolicy.ANY_RESOURCE, | ||
}), | ||
}); | ||
|
||
this.serviceSpecificCredentialId = codeCommitCredentialsResponse.getResponseField("ServiceSpecificCredential.ServiceSpecificCredentialId"); | ||
this.serviceName = codeCommitCredentialsResponse.getResponseField("ServiceSpecificCredential.ServiceName"); | ||
this.serviceUserName = codeCommitCredentialsResponse.getResponseField("ServiceSpecificCredential.ServiceUserName"); | ||
this.servicePassword = codeCommitCredentialsResponse.getResponseField("ServiceSpecificCredential.ServicePassword"); | ||
this.status = codeCommitCredentialsResponse.getResponseField("ServiceSpecificCredential.Status"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters