TypeScritp を書いた時の自分用メモ。
(TypeScript の事はよく分かっていません。。。)
メモなのでかなり雑記
変数展開したい
バッククオート(`)で囲って、展開したいときは ${valname}
という形式で書く
Interface って何?
ここら辺を読んだ
今回「Import 先のファイルに指定してある interface を引数とするコンストラクタを使う」という場合で以下のような感じで出来た。
import core = require('@aws-cdk/core');
import cognito = require('@aws-cdk/aws-cognito');
export class HelloCdkStack extends core.Stack {
constructor(scope: core.App, id: string, props?: core.StackProps) {
super(scope, id, props);
var myObj:cognito.CfnIdentityPoolRoleAttachment.RoleMappingProperty = {type: 'Token', identityProvider: 'cog
nito-idp.ap-northeast-1.amazonaws.com/ap-northeast-xxxxx:xxxx', ambiguousRoleResolution: 'AuthenticatedRole'};
new cognito.CfnIdentityPoolRoleAttachment(this, 'UserPool1RoleMapping', {
identityPoolId: 'ap-northeast-1:xxx2',
roles: {
'authenticated': 'arn:aws:iam::xxxx:role/Cognito_xxxxAuth_Role'
},
roleMappings: {
myObj
}
});
}
}
Import 先で設定されている Interface の抜粋
export declare namespace CfnIdentityPoolRoleAttachment {
/**
* @stability external
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-identitypoolroleattachment-rolemapping.html
*/
interface RoleMappingProperty {
/**
* `CfnIdentityPoolRoleAttachment.RoleMappingProperty.AmbiguousRoleResolution`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-identitypoolroleattachment-rolemapping.html#cfn-cognito-identitypoolroleattachment-rolemapping-ambiguousroleresolution
*/
readonly ambiguousRoleResolution?: string;
/**
* `CfnIdentityPoolRoleAttachment.RoleMappingProperty.IdentityProvider`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-identitypoolroleattachment-rolemapping.html#cfn-cognito-identitypoolroleattachment-rolemapping-identityprovider
*/
readonly identityProvider?: string;
/**
* `CfnIdentityPoolRoleAttachment.RoleMappingProperty.RulesConfiguration`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-identitypoolroleattachment-rolemapping.html#cfn-cognito-identitypoolroleattachment-rolemapping-rulesconfiguration
*/
readonly rulesConfiguration?: CfnIdentityPoolRoleAttachment.RulesConfigurationTypeProperty | cdk.IResolvable;
/**
* `CfnIdentityPoolRoleAttachment.RoleMappingProperty.Type`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-identitypoolroleattachment-rolemapping.html#cfn-cognito-identitypoolroleattachment-rolemapping-type
*/
readonly type: string;
}
}
Interface の ? って何?
Interfaceの使い方(型注釈, implements)
? は省略可能という意味らしい
readonly は読み込み専用らしい