Example usage for com.amazonaws.services.securitytoken.model GetCallerIdentityResult getAccount

List of usage examples for com.amazonaws.services.securitytoken.model GetCallerIdentityResult getAccount

Introduction

In this page you can find the example usage for com.amazonaws.services.securitytoken.model GetCallerIdentityResult getAccount.

Prototype


public String getAccount() 

Source Link

Document

The AWS account ID number of the account that owns or contains the calling entity.

Usage

From source file:com.github.kaklakariada.aws.sam.service.AwsMetadataService.java

License:Open Source License

public String getAccountId() {
    final GetCallerIdentityResult callerIdentity = tokenService
            .getCallerIdentity(new GetCallerIdentityRequest());
    return callerIdentity.getAccount();
}

From source file:com.nike.cerberus.operation.cms.CreateCmsConfigOperation.java

License:Apache License

@Override
public void run(final CreateCmsConfigCommand command) {
    configStore.storeCmsAdminGroup(command.getAdminGroup());

    final BaseOutputs baseOutputs = configStore.getBaseStackOutputs();
    final BaseParameters baseParameters = configStore.getBaseStackParameters();
    final VaultParameters vaultParameters = configStore.getVaultStackParamters();
    final GetCallerIdentityResult callerIdentity = securityTokenService
            .getCallerIdentity(new GetCallerIdentityRequest());
    final Optional<String> cmsVaultToken = configStore.getCmsVaultToken();
    final Optional<String> cmsDatabasePassword = configStore.getCmsDatabasePassword();

    final Map<String, String> cmsConfigMap = Maps.newHashMap();
    final String rootUserArn = String.format("arn:aws:iam::%s:root", callerIdentity.getAccount());

    cmsConfigMap.put("vault.addr", String.format("https://%s", cnameToHost(vaultParameters.getCname())));
    cmsConfigMap.put("vault.token", cmsVaultToken.get());
    cmsConfigMap.put("cms.admin.group", command.getAdminGroup());
    cmsConfigMap.put("root.user.arn", rootUserArn);
    cmsConfigMap.put("admin.role.arn", baseParameters.getAccountAdminArn());
    cmsConfigMap.put("cms.role.arn", baseOutputs.getCmsIamRoleArn());
    cmsConfigMap.put("JDBC.url", baseOutputs.getCmsDbJdbcConnectionString());
    cmsConfigMap.put("JDBC.username", ConfigConstants.DEFAULT_CMS_DB_NAME);
    cmsConfigMap.put("JDBC.password", cmsDatabasePassword.get());

    command.getAdditionalProperties().forEach((k, v) -> {
        if (!cmsConfigMap.containsKey(k)) {
            cmsConfigMap.put(k, v);/*from   w w w  .j a v  a  2  s  . c om*/
        } else {
            logger.warn("Ignoring additional property that would override system configured property, " + k);
        }
    });

    configStore.storeCmsEnvConfig(cmsConfigMap);
}